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

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

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

namespace MFAPI {

using namespace std;

// CancelRejectReason {

    bool CancelRejectReason::_initialized = false;

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

    const unsigned int CancelRejectReason::_maxValue = 255;
    const unsigned int CancelRejectReason::_nbValues = 20;

    const char* CancelRejectReason::_names[255];
    unsigned char CancelRejectReason::_toIndex[255];
    CancelRejectReason::Type CancelRejectReason::_fromIndex[20];

    void CancelRejectReason::initializeEnum()
    {
        const char* dummy = 0;
        std::fill_n(_names, 255, dummy);
        _names[TOO_LATE_TO_CANCEL] = "TOO_LATE_TO_CANCEL";
        _names[UNKNOWN_ORDER] = "UNKNOWN_ORDER";
        _names[DUPLICATE_CLORDID_RECEIVED] = "DUPLICATE_CLORDID_RECEIVED";
        _names[INVALID_CANCEL] = "INVALID_CANCEL";
        _names[OTHER] = "OTHER";
        _names[ORDER_NOT_ACTIVE] = "ORDER_NOT_ACTIVE";
        _names[INVALID_FEED] = "INVALID_FEED";
        _names[INVALID_MARKET] = "INVALID_MARKET";
        _names[NOT_IMPLEMENTED] = "NOT_IMPLEMENTED";
        _names[FEED_DOWN] = "FEED_DOWN";
        _names[TOO_MANY_ORDER_SUBMITS] = "TOO_MANY_ORDER_SUBMITS";
        _names[RESEND_REQUESTED] = "RESEND_REQUESTED";
        _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[NOT_APPLICABLE] = "NOT_APPLICABLE";

        unsigned char idx = 0;
        _toIndex[CancelRejectReason::TOO_LATE_TO_CANCEL] = idx;
        _fromIndex[idx] = CancelRejectReason::TOO_LATE_TO_CANCEL;
        idx++;
        _toIndex[CancelRejectReason::UNKNOWN_ORDER] = idx;
        _fromIndex[idx] = CancelRejectReason::UNKNOWN_ORDER;
        idx++;
        _toIndex[CancelRejectReason::DUPLICATE_CLORDID_RECEIVED] = idx;
        _fromIndex[idx] = CancelRejectReason::DUPLICATE_CLORDID_RECEIVED;
        idx++;
        _toIndex[CancelRejectReason::INVALID_CANCEL] = idx;
        _fromIndex[idx] = CancelRejectReason::INVALID_CANCEL;
        idx++;
        _toIndex[CancelRejectReason::OTHER] = idx;
        _fromIndex[idx] = CancelRejectReason::OTHER;
        idx++;
        _toIndex[CancelRejectReason::ORDER_NOT_ACTIVE] = idx;
        _fromIndex[idx] = CancelRejectReason::ORDER_NOT_ACTIVE;
        idx++;
        _toIndex[CancelRejectReason::INVALID_FEED] = idx;
        _fromIndex[idx] = CancelRejectReason::INVALID_FEED;
        idx++;
        _toIndex[CancelRejectReason::INVALID_MARKET] = idx;
        _fromIndex[idx] = CancelRejectReason::INVALID_MARKET;
        idx++;
        _toIndex[CancelRejectReason::NOT_IMPLEMENTED] = idx;
        _fromIndex[idx] = CancelRejectReason::NOT_IMPLEMENTED;
        idx++;
        _toIndex[CancelRejectReason::FEED_DOWN] = idx;
        _fromIndex[idx] = CancelRejectReason::FEED_DOWN;
        idx++;
        _toIndex[CancelRejectReason::TOO_MANY_ORDER_SUBMITS] = idx;
        _fromIndex[idx] = CancelRejectReason::TOO_MANY_ORDER_SUBMITS;
        idx++;
        _toIndex[CancelRejectReason::RESEND_REQUESTED] = idx;
        _fromIndex[idx] = CancelRejectReason::RESEND_REQUESTED;
        idx++;
        _toIndex[CancelRejectReason::LOCKED_USER] = idx;
        _fromIndex[idx] = CancelRejectReason::LOCKED_USER;
        idx++;
        _toIndex[CancelRejectReason::EXCEEDS_NOP_LIMIT] = idx;
        _fromIndex[idx] = CancelRejectReason::EXCEEDS_NOP_LIMIT;
        idx++;
        _toIndex[CancelRejectReason::EXCEEDS_DSL_LIMIT] = idx;
        _fromIndex[idx] = CancelRejectReason::EXCEEDS_DSL_LIMIT;
        idx++;
        _toIndex[CancelRejectReason::EXCEEDS_POSITION_LIMIT] = idx;
        _fromIndex[idx] = CancelRejectReason::EXCEEDS_POSITION_LIMIT;
        idx++;
        _toIndex[CancelRejectReason::EXCEEDS_PENDING_LIMIT] = idx;
        _fromIndex[idx] = CancelRejectReason::EXCEEDS_PENDING_LIMIT;
        idx++;
        _toIndex[CancelRejectReason::EXCEEDS_SINGLE_LIMIT] = idx;
        _fromIndex[idx] = CancelRejectReason::EXCEEDS_SINGLE_LIMIT;
        idx++;
        _toIndex[CancelRejectReason::TRADE_LIMIT_RESTRICTION] = idx;
        _fromIndex[idx] = CancelRejectReason::TRADE_LIMIT_RESTRICTION;
        idx++;
        _toIndex[CancelRejectReason::NOT_APPLICABLE] = idx;
        _fromIndex[idx] = CancelRejectReason::NOT_APPLICABLE;
        idx++;

        _initialized = true;
    }

    void CancelRejectReason::finalizeEnum()
    {
    }

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

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

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

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

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

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

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

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