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

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

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

namespace MFAPI {

using namespace std;

// RejectReason {

    bool RejectReason::_initialized = false;

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

    const unsigned int RejectReason::_maxValue = 255;
    const unsigned int RejectReason::_nbValues = 27;

    const char* RejectReason::_names[255];
    unsigned char RejectReason::_toIndex[255];
    RejectReason::Type RejectReason::_fromIndex[27];

    void RejectReason::initializeEnum()
    {
        const char* dummy = 0;
        std::fill_n(_names, 255, dummy);
        _names[NOT_SUBSCRIBED] = "NOT_SUBSCRIBED";
        _names[UNKNOWN_SYMBOL] = "UNKNOWN_SYMBOL";
        _names[EXCHANGE_NOT_AVAILABLE] = "EXCHANGE_NOT_AVAILABLE";
        _names[CREDIT_LOW] = "CREDIT_LOW";
        _names[DUPLICATE_ORDER] = "DUPLICATE_ORDER";
        _names[INCORRECT_QUANTITY] = "INCORRECT_QUANTITY";
        _names[INCORRECT_PRICE] = "INCORRECT_PRICE";
        _names[INVALID_ORDER] = "INVALID_ORDER";
        _names[INVALID_FEED] = "INVALID_FEED";
        _names[INVALID_MARKET] = "INVALID_MARKET";
        _names[FEED_DOWN] = "FEED_DOWN";
        _names[INVALID_ORDER_TYPE] = "INVALID_ORDER_TYPE";
        _names[INVALID_TIME_IN_FORCE] = "INVALID_TIME_IN_FORCE";
        _names[INVALID_CLORDID] = "INVALID_CLORDID";
        _names[UNKNOWN_ORDER] = "UNKNOWN_ORDER";
        _names[TOO_MANY_ORDER_SUBMITS] = "TOO_MANY_ORDER_SUBMITS";
        _names[RESEND_REQUESTED] = "RESEND_REQUESTED";
        _names[MARKET_NOT_ACTIVE] = "MARKET_NOT_ACTIVE";
        _names[LOCKED_USER] = "LOCKED_USER";
        _names[EXCEEDS_NOP_LIMIT] = "EXCEEDS_NOP_LIMIT";
        _names[EXCEEDS_DSL_LIMIT] = "EXCEEDS_DSL_LIMIT";
        _names[EXCEEDS_POSITION_LIMIT] = "EXCEEDS_POSITION_LIMIT";
        _names[EXCEEDS_PENDING_LIMIT] = "EXCEEDS_PENDING_LIMIT";
        _names[EXCEEDS_SINGLE_LIMIT] = "EXCEEDS_SINGLE_LIMIT";
        _names[TRADE_LIMIT_RESTRICTION] = "TRADE_LIMIT_RESTRICTION";
        _names[INVALID_MODEL] = "INVALID_MODEL";
        _names[NOT_APPLICABLE] = "NOT_APPLICABLE";

        unsigned char idx = 0;
        _toIndex[RejectReason::NOT_SUBSCRIBED] = idx;
        _fromIndex[idx] = RejectReason::NOT_SUBSCRIBED;
        idx++;
        _toIndex[RejectReason::UNKNOWN_SYMBOL] = idx;
        _fromIndex[idx] = RejectReason::UNKNOWN_SYMBOL;
        idx++;
        _toIndex[RejectReason::EXCHANGE_NOT_AVAILABLE] = idx;
        _fromIndex[idx] = RejectReason::EXCHANGE_NOT_AVAILABLE;
        idx++;
        _toIndex[RejectReason::CREDIT_LOW] = idx;
        _fromIndex[idx] = RejectReason::CREDIT_LOW;
        idx++;
        _toIndex[RejectReason::DUPLICATE_ORDER] = idx;
        _fromIndex[idx] = RejectReason::DUPLICATE_ORDER;
        idx++;
        _toIndex[RejectReason::INCORRECT_QUANTITY] = idx;
        _fromIndex[idx] = RejectReason::INCORRECT_QUANTITY;
        idx++;
        _toIndex[RejectReason::INCORRECT_PRICE] = idx;
        _fromIndex[idx] = RejectReason::INCORRECT_PRICE;
        idx++;
        _toIndex[RejectReason::INVALID_ORDER] = idx;
        _fromIndex[idx] = RejectReason::INVALID_ORDER;
        idx++;
        _toIndex[RejectReason::INVALID_FEED] = idx;
        _fromIndex[idx] = RejectReason::INVALID_FEED;
        idx++;
        _toIndex[RejectReason::INVALID_MARKET] = idx;
        _fromIndex[idx] = RejectReason::INVALID_MARKET;
        idx++;
        _toIndex[RejectReason::FEED_DOWN] = idx;
        _fromIndex[idx] = RejectReason::FEED_DOWN;
        idx++;
        _toIndex[RejectReason::INVALID_ORDER_TYPE] = idx;
        _fromIndex[idx] = RejectReason::INVALID_ORDER_TYPE;
        idx++;
        _toIndex[RejectReason::INVALID_TIME_IN_FORCE] = idx;
        _fromIndex[idx] = RejectReason::INVALID_TIME_IN_FORCE;
        idx++;
        _toIndex[RejectReason::INVALID_CLORDID] = idx;
        _fromIndex[idx] = RejectReason::INVALID_CLORDID;
        idx++;
        _toIndex[RejectReason::UNKNOWN_ORDER] = idx;
        _fromIndex[idx] = RejectReason::UNKNOWN_ORDER;
        idx++;
        _toIndex[RejectReason::TOO_MANY_ORDER_SUBMITS] = idx;
        _fromIndex[idx] = RejectReason::TOO_MANY_ORDER_SUBMITS;
        idx++;
        _toIndex[RejectReason::RESEND_REQUESTED] = idx;
        _fromIndex[idx] = RejectReason::RESEND_REQUESTED;
        idx++;
        _toIndex[RejectReason::MARKET_NOT_ACTIVE] = idx;
        _fromIndex[idx] = RejectReason::MARKET_NOT_ACTIVE;
        idx++;
        _toIndex[RejectReason::LOCKED_USER] = idx;
        _fromIndex[idx] = RejectReason::LOCKED_USER;
        idx++;
        _toIndex[RejectReason::EXCEEDS_NOP_LIMIT] = idx;
        _fromIndex[idx] = RejectReason::EXCEEDS_NOP_LIMIT;
        idx++;
        _toIndex[RejectReason::EXCEEDS_DSL_LIMIT] = idx;
        _fromIndex[idx] = RejectReason::EXCEEDS_DSL_LIMIT;
        idx++;
        _toIndex[RejectReason::EXCEEDS_POSITION_LIMIT] = idx;
        _fromIndex[idx] = RejectReason::EXCEEDS_POSITION_LIMIT;
        idx++;
        _toIndex[RejectReason::EXCEEDS_PENDING_LIMIT] = idx;
        _fromIndex[idx] = RejectReason::EXCEEDS_PENDING_LIMIT;
        idx++;
        _toIndex[RejectReason::EXCEEDS_SINGLE_LIMIT] = idx;
        _fromIndex[idx] = RejectReason::EXCEEDS_SINGLE_LIMIT;
        idx++;
        _toIndex[RejectReason::TRADE_LIMIT_RESTRICTION] = idx;
        _fromIndex[idx] = RejectReason::TRADE_LIMIT_RESTRICTION;
        idx++;
        _toIndex[RejectReason::INVALID_MODEL] = idx;
        _fromIndex[idx] = RejectReason::INVALID_MODEL;
        idx++;
        _toIndex[RejectReason::NOT_APPLICABLE] = idx;
        _fromIndex[idx] = RejectReason::NOT_APPLICABLE;
        idx++;

        _initialized = true;
    }

    void RejectReason::finalizeEnum()
    {
    }

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

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

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

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

    RejectReason::Type RejectReason::fromString( const char* s )
    {
        assert(_initialized);
        if ( s == 0 ) {
            throw std::invalid_argument("Empty string for converting to enum RejectReason.");
        }
        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 RejectReason." << std::ends;
        throw std::invalid_argument(oss.str().c_str());
    }

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

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

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