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

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

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

namespace MFAPI {

using namespace std;

// APIResult {

    bool APIResult::_initialized = false;

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

    const unsigned int APIResult::_maxValue = 255;
    const unsigned int APIResult::_nbValues = 37;

    const char* APIResult::_names[255];
    unsigned char APIResult::_toIndex[255];
    APIResult::Type APIResult::_fromIndex[37];

    void APIResult::initializeEnum()
    {
        const char* dummy = 0;
        std::fill_n(_names, 255, dummy);
        _names[OK] = "OK";
        _names[COULD_NOT_CONNECT] = "COULD_NOT_CONNECT";
        _names[TIMEOUT] = "TIMEOUT";
        _names[BUFFER_FULL] = "BUFFER_FULL";
        _names[COULD_NOT_OPEN] = "COULD_NOT_OPEN";
        _names[SOCKERR_DNS] = "SOCKERR_DNS";
        _names[SOCKERR_CREATE] = "SOCKERR_CREATE";
        _names[SOCKERR_CONNECT] = "SOCKERR_CONNECT";
        _names[SOCKERR_CLOSED] = "SOCKERR_CLOSED";
        _names[SOCKERR_READING] = "SOCKERR_READING";
        _names[SOCKERR_WRITING] = "SOCKERR_WRITING";
        _names[NOT_CONNECTED] = "NOT_CONNECTED";
        _names[NOT_RUNNING] = "NOT_RUNNING";
        _names[IS_CONNECTED] = "IS_CONNECTED";
        _names[IS_RUNNING] = "IS_RUNNING";
        _names[IS_STOPPING] = "IS_STOPPING";
        _names[EXCEPTION_THROWN] = "EXCEPTION_THROWN";
        _names[PROTOCOL_ERROR] = "PROTOCOL_ERROR";
        _names[INCOMPATIBLE_PROTOCOL] = "INCOMPATIBLE_PROTOCOL";
        _names[INVALID_USER] = "INVALID_USER";
        _names[INVALID_PASSWORD] = "INVALID_PASSWORD";
        _names[USER_ALREADY_CONNECTED] = "USER_ALREADY_CONNECTED";
        _names[COULD_NOT_LOGIN] = "COULD_NOT_LOGIN";
        _names[INVALID_FEED] = "INVALID_FEED";
        _names[INVALID_MARKET] = "INVALID_MARKET";
        _names[INVALID_ORDERID] = "INVALID_ORDERID";
        _names[INVALID_BATCHID] = "INVALID_BATCHID";
        _names[INVALID_CLIENT_ORDERID] = "INVALID_CLIENT_ORDERID";
        _names[DUPLICATE_CLIENT_ORDERID] = "DUPLICATE_CLIENT_ORDERID";
        _names[INVALID_MARKETDATA_FEED] = "INVALID_MARKETDATA_FEED";
        _names[INVALID_TRADING_FEED] = "INVALID_TRADING_FEED";
        _names[USER_LOCKED] = "USER_LOCKED";
        _names[SYSTEM_LOCKED] = "SYSTEM_LOCKED";
        _names[ADMIN_HANDLER_FAULT] = "ADMIN_HANDLER_FAULT";
        _names[INVALID_PARAMETER] = "INVALID_PARAMETER";
        _names[NOT_IMPLEMENTED] = "NOT_IMPLEMENTED";
        _names[NOT_APPLICABLE] = "NOT_APPLICABLE";

        unsigned char idx = 0;
        _toIndex[APIResult::OK] = idx;
        _fromIndex[idx] = APIResult::OK;
        idx++;
        _toIndex[APIResult::COULD_NOT_CONNECT] = idx;
        _fromIndex[idx] = APIResult::COULD_NOT_CONNECT;
        idx++;
        _toIndex[APIResult::TIMEOUT] = idx;
        _fromIndex[idx] = APIResult::TIMEOUT;
        idx++;
        _toIndex[APIResult::BUFFER_FULL] = idx;
        _fromIndex[idx] = APIResult::BUFFER_FULL;
        idx++;
        _toIndex[APIResult::COULD_NOT_OPEN] = idx;
        _fromIndex[idx] = APIResult::COULD_NOT_OPEN;
        idx++;
        _toIndex[APIResult::SOCKERR_DNS] = idx;
        _fromIndex[idx] = APIResult::SOCKERR_DNS;
        idx++;
        _toIndex[APIResult::SOCKERR_CREATE] = idx;
        _fromIndex[idx] = APIResult::SOCKERR_CREATE;
        idx++;
        _toIndex[APIResult::SOCKERR_CONNECT] = idx;
        _fromIndex[idx] = APIResult::SOCKERR_CONNECT;
        idx++;
        _toIndex[APIResult::SOCKERR_CLOSED] = idx;
        _fromIndex[idx] = APIResult::SOCKERR_CLOSED;
        idx++;
        _toIndex[APIResult::SOCKERR_READING] = idx;
        _fromIndex[idx] = APIResult::SOCKERR_READING;
        idx++;
        _toIndex[APIResult::SOCKERR_WRITING] = idx;
        _fromIndex[idx] = APIResult::SOCKERR_WRITING;
        idx++;
        _toIndex[APIResult::NOT_CONNECTED] = idx;
        _fromIndex[idx] = APIResult::NOT_CONNECTED;
        idx++;
        _toIndex[APIResult::NOT_RUNNING] = idx;
        _fromIndex[idx] = APIResult::NOT_RUNNING;
        idx++;
        _toIndex[APIResult::IS_CONNECTED] = idx;
        _fromIndex[idx] = APIResult::IS_CONNECTED;
        idx++;
        _toIndex[APIResult::IS_RUNNING] = idx;
        _fromIndex[idx] = APIResult::IS_RUNNING;
        idx++;
        _toIndex[APIResult::IS_STOPPING] = idx;
        _fromIndex[idx] = APIResult::IS_STOPPING;
        idx++;
        _toIndex[APIResult::EXCEPTION_THROWN] = idx;
        _fromIndex[idx] = APIResult::EXCEPTION_THROWN;
        idx++;
        _toIndex[APIResult::PROTOCOL_ERROR] = idx;
        _fromIndex[idx] = APIResult::PROTOCOL_ERROR;
        idx++;
        _toIndex[APIResult::INCOMPATIBLE_PROTOCOL] = idx;
        _fromIndex[idx] = APIResult::INCOMPATIBLE_PROTOCOL;
        idx++;
        _toIndex[APIResult::INVALID_USER] = idx;
        _fromIndex[idx] = APIResult::INVALID_USER;
        idx++;
        _toIndex[APIResult::INVALID_PASSWORD] = idx;
        _fromIndex[idx] = APIResult::INVALID_PASSWORD;
        idx++;
        _toIndex[APIResult::USER_ALREADY_CONNECTED] = idx;
        _fromIndex[idx] = APIResult::USER_ALREADY_CONNECTED;
        idx++;
        _toIndex[APIResult::COULD_NOT_LOGIN] = idx;
        _fromIndex[idx] = APIResult::COULD_NOT_LOGIN;
        idx++;
        _toIndex[APIResult::INVALID_FEED] = idx;
        _fromIndex[idx] = APIResult::INVALID_FEED;
        idx++;
        _toIndex[APIResult::INVALID_MARKET] = idx;
        _fromIndex[idx] = APIResult::INVALID_MARKET;
        idx++;
        _toIndex[APIResult::INVALID_ORDERID] = idx;
        _fromIndex[idx] = APIResult::INVALID_ORDERID;
        idx++;
        _toIndex[APIResult::INVALID_BATCHID] = idx;
        _fromIndex[idx] = APIResult::INVALID_BATCHID;
        idx++;
        _toIndex[APIResult::INVALID_CLIENT_ORDERID] = idx;
        _fromIndex[idx] = APIResult::INVALID_CLIENT_ORDERID;
        idx++;
        _toIndex[APIResult::DUPLICATE_CLIENT_ORDERID] = idx;
        _fromIndex[idx] = APIResult::DUPLICATE_CLIENT_ORDERID;
        idx++;
        _toIndex[APIResult::INVALID_MARKETDATA_FEED] = idx;
        _fromIndex[idx] = APIResult::INVALID_MARKETDATA_FEED;
        idx++;
        _toIndex[APIResult::INVALID_TRADING_FEED] = idx;
        _fromIndex[idx] = APIResult::INVALID_TRADING_FEED;
        idx++;
        _toIndex[APIResult::USER_LOCKED] = idx;
        _fromIndex[idx] = APIResult::USER_LOCKED;
        idx++;
        _toIndex[APIResult::SYSTEM_LOCKED] = idx;
        _fromIndex[idx] = APIResult::SYSTEM_LOCKED;
        idx++;
        _toIndex[APIResult::ADMIN_HANDLER_FAULT] = idx;
        _fromIndex[idx] = APIResult::ADMIN_HANDLER_FAULT;
        idx++;
        _toIndex[APIResult::INVALID_PARAMETER] = idx;
        _fromIndex[idx] = APIResult::INVALID_PARAMETER;
        idx++;
        _toIndex[APIResult::NOT_IMPLEMENTED] = idx;
        _fromIndex[idx] = APIResult::NOT_IMPLEMENTED;
        idx++;
        _toIndex[APIResult::NOT_APPLICABLE] = idx;
        _fromIndex[idx] = APIResult::NOT_APPLICABLE;
        idx++;

        _initialized = true;
    }

    void APIResult::finalizeEnum()
    {
    }

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

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

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

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

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

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

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

    std::ostream& operator<<( std::ostream& os, APIResult::Type en )
    {
        os << APIResult::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 
*/
