// Copyright (C) 2010-2016  MarketFactory, Inc. All Rights Reserved.
//================================================================================
//   This file is auto-generated; DO NOT EDIT!
//================================================================================

#include <API/Clients/CPP/Proto/SubscriptionStatus.h>

#include <iostream>
#include <cassert>
#include <stdexcept>
#include <string.h>
#include <sstream>

namespace MFAPI {

using namespace std;

// SubscriptionStatus {

    bool SubscriptionStatus::_initialized = false;

    const char* SubscriptionStatus::Name = "SubscriptionStatus";

    const unsigned int SubscriptionStatus::_maxValue = 4;
    const unsigned int SubscriptionStatus::_nbValues = 4;

    const char* SubscriptionStatus::_names[4];
    unsigned char SubscriptionStatus::_toIndex[4];
    SubscriptionStatus::Type SubscriptionStatus::_fromIndex[4];

    void SubscriptionStatus::initializeEnum()
    {
        const char* dummy = 0;
        std::fill_n(_names, 4, dummy);
        _names[INVALID] = "INVALID";
        _names[ENABLED] = "ENABLED";
        _names[DISABLED] = "DISABLED";
        _names[ERROR] = "ERROR";

        unsigned char idx = 0;
        _toIndex[SubscriptionStatus::INVALID] = idx;
        _fromIndex[idx] = SubscriptionStatus::INVALID;
        idx++;
        _toIndex[SubscriptionStatus::ENABLED] = idx;
        _fromIndex[idx] = SubscriptionStatus::ENABLED;
        idx++;
        _toIndex[SubscriptionStatus::DISABLED] = idx;
        _fromIndex[idx] = SubscriptionStatus::DISABLED;
        idx++;
        _toIndex[SubscriptionStatus::ERROR] = idx;
        _fromIndex[idx] = SubscriptionStatus::ERROR;
        idx++;

        _initialized = true;
    }

    void SubscriptionStatus::finalizeEnum()
    {
    }

    bool SubscriptionStatus::isValid( unsigned char iv )
    {
        assert(_initialized);
        return SubscriptionStatus::_names[iv] != 0;
    }

    unsigned char SubscriptionStatus::toValue( SubscriptionStatus::Type iv )
    {
        return static_cast<unsigned char>(iv);
    }

    SubscriptionStatus::Type SubscriptionStatus::fromValue( unsigned char iv )
    {
        if ( !isValid(iv) ) {
            std::ostringstream oss;
            oss << "Invalid value for SubscriptionStatus: " << iv << std::ends;
            throw std::invalid_argument(oss.str().c_str());
        }
        return Type(iv);
    }

    const char* SubscriptionStatus::toString( unsigned char iv )
    {
        assert(_initialized);
        return SubscriptionStatus::_names[iv];
    }

    SubscriptionStatus::Type SubscriptionStatus::fromString( const char* s )
    {
        assert(_initialized);
        if ( s == 0 ) {
            throw std::invalid_argument("Empty string for converting to enum SubscriptionStatus.");
        }
        for ( int ii = 0; ii < 4; ++ii ) {
            if ( _names[ii] != 0 && strcmp(s, _names[ii]) == 0 ) {
                return Type(ii);
            }
        }
        std::ostringstream oss;
        oss << "Invalid string '" << s << "' for converting to enum SubscriptionStatus." << std::ends;
        throw std::invalid_argument(oss.str().c_str());
    }

    unsigned char SubscriptionStatus::toIndex( Type en )
    {
        return _toIndex[en];
    }

    SubscriptionStatus::Type SubscriptionStatus::fromIndex( unsigned char index )
    {
        return _fromIndex[index];
    }

    std::ostream& operator<<( std::ostream& os, SubscriptionStatus::Type en )
    {
        os << SubscriptionStatus::toString(en);
        return os;
    }

// }
} // MFAPI

/*
Brought to you by
/opt/atlassian/bamboo-agent/xml-data/build-dir/GAT-GWY-B3/Messaging/main.py --root /opt/atlassian/bamboo-agent/xml-data/build-dir/GAT-GWY-B3 --commit-date 2016-12-06T18:11:31.205-05:00 --revision 19c07f7ab2ea0612a19fbcabdd4a54e242830e7d --branch master --generated_directory /opt/atlassian/bamboo-agent/xml-data/build-dir/GAT-GWY-B3/build/rh7_3.13.0/release/intel64/generated/Python -o /opt/atlassian/bamboo-agent/xml-data/build-dir/GAT-GWY-B3/build/rh7_3.13.0/release/intel64/generated/API/Clients/CPP/Proto -i /opt/atlassian/bamboo-agent/xml-data/build-dir/GAT-GWY-B3/Messaging/MFProtocol --namespace=MFAPI cppapi /opt/atlassian/bamboo-agent/xml-data/build-dir/GAT-GWY-B3/Messaging/MFProtocol.proto.3130 /opt/atlassian/bamboo-agent/xml-data/build-dir/GAT-GWY-B3/Messaging/MFObsolete.proto.3130 
*/
