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

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

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

namespace MFAPI {

using namespace std;

// MDElement {

    bool MDElement::_initialized = false;

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

    const unsigned int MDElement::_maxValue = 14;
    const unsigned int MDElement::_nbValues = 13;

    const char* MDElement::_names[14];
    unsigned char MDElement::_toIndex[14];
    MDElement::Type MDElement::_fromIndex[13];

    void MDElement::initializeEnum()
    {
        const char* dummy = 0;
        std::fill_n(_names, 14, dummy);
        _names[LEVEL] = "LEVEL";
        _names[AMOUNT_CONS] = "AMOUNT_CONS";
        _names[SPREAD_CONS] = "SPREAD_CONS";
        _names[LOCAL_BEST] = "LOCAL_BEST";
        _names[EXCHANGE_BEST] = "EXCHANGE_BEST";
        _names[LAST_TRADE] = "LAST_TRADE";
        _names[LAST_TRADE_NO_SIDE] = "LAST_TRADE_NO_SIDE";
        _names[WORST_TRADE] = "WORST_TRADE";
        _names[LEVEL_QUOTE] = "LEVEL_QUOTE";
        _names[LEVEL_QUOTE_AMT_TIER] = "LEVEL_QUOTE_AMT_TIER";
        _names[QUOTE] = "QUOTE";
        _names[QUOTE_AMT_TIER] = "QUOTE_AMT_TIER";
        _names[ORDER] = "ORDER";

        unsigned char idx = 0;
        _toIndex[MDElement::LEVEL] = idx;
        _fromIndex[idx] = MDElement::LEVEL;
        idx++;
        _toIndex[MDElement::AMOUNT_CONS] = idx;
        _fromIndex[idx] = MDElement::AMOUNT_CONS;
        idx++;
        _toIndex[MDElement::SPREAD_CONS] = idx;
        _fromIndex[idx] = MDElement::SPREAD_CONS;
        idx++;
        _toIndex[MDElement::LOCAL_BEST] = idx;
        _fromIndex[idx] = MDElement::LOCAL_BEST;
        idx++;
        _toIndex[MDElement::EXCHANGE_BEST] = idx;
        _fromIndex[idx] = MDElement::EXCHANGE_BEST;
        idx++;
        _toIndex[MDElement::LAST_TRADE] = idx;
        _fromIndex[idx] = MDElement::LAST_TRADE;
        idx++;
        _toIndex[MDElement::LAST_TRADE_NO_SIDE] = idx;
        _fromIndex[idx] = MDElement::LAST_TRADE_NO_SIDE;
        idx++;
        _toIndex[MDElement::WORST_TRADE] = idx;
        _fromIndex[idx] = MDElement::WORST_TRADE;
        idx++;
        _toIndex[MDElement::LEVEL_QUOTE] = idx;
        _fromIndex[idx] = MDElement::LEVEL_QUOTE;
        idx++;
        _toIndex[MDElement::LEVEL_QUOTE_AMT_TIER] = idx;
        _fromIndex[idx] = MDElement::LEVEL_QUOTE_AMT_TIER;
        idx++;
        _toIndex[MDElement::QUOTE] = idx;
        _fromIndex[idx] = MDElement::QUOTE;
        idx++;
        _toIndex[MDElement::QUOTE_AMT_TIER] = idx;
        _fromIndex[idx] = MDElement::QUOTE_AMT_TIER;
        idx++;
        _toIndex[MDElement::ORDER] = idx;
        _fromIndex[idx] = MDElement::ORDER;
        idx++;

        _initialized = true;
    }

    void MDElement::finalizeEnum()
    {
    }

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

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

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

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

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

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

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

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