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

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

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

namespace MFAPI {

using namespace std;

// RiskStatus {

    bool RiskStatus::_initialized = false;

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

    const unsigned int RiskStatus::_maxValue = 21;
    const unsigned int RiskStatus::_nbValues = 12;

    const char* RiskStatus::_names[21];
    unsigned char RiskStatus::_toIndex[21];
    RiskStatus::Type RiskStatus::_fromIndex[12];

    void RiskStatus::initializeEnum()
    {
        const char* dummy = 0;
        std::fill_n(_names, 21, dummy);
        _names[SUCCESS] = "SUCCESS";
        _names[INVALID_PERMISSIONS] = "INVALID_PERMISSIONS";
        _names[INVALID_GROUP] = "INVALID_GROUP";
        _names[INVALID_USER] = "INVALID_USER";
        _names[INVALID_ADMIN] = "INVALID_ADMIN";
        _names[INVALID_FEED] = "INVALID_FEED";
        _names[INVALID_MARKET] = "INVALID_MARKET";
        _names[INVALID_SETTLDATE] = "INVALID_SETTLDATE";
        _names[INVALID_AMOUNT] = "INVALID_AMOUNT";
        _names[INVALID_DROPCOPY_SEQID] = "INVALID_DROPCOPY_SEQID";
        _names[INVALID_DROPCOPY_FEED] = "INVALID_DROPCOPY_FEED";
        _names[MISSING_RISK_DATA] = "MISSING_RISK_DATA";

        unsigned char idx = 0;
        _toIndex[RiskStatus::SUCCESS] = idx;
        _fromIndex[idx] = RiskStatus::SUCCESS;
        idx++;
        _toIndex[RiskStatus::INVALID_PERMISSIONS] = idx;
        _fromIndex[idx] = RiskStatus::INVALID_PERMISSIONS;
        idx++;
        _toIndex[RiskStatus::INVALID_GROUP] = idx;
        _fromIndex[idx] = RiskStatus::INVALID_GROUP;
        idx++;
        _toIndex[RiskStatus::INVALID_USER] = idx;
        _fromIndex[idx] = RiskStatus::INVALID_USER;
        idx++;
        _toIndex[RiskStatus::INVALID_ADMIN] = idx;
        _fromIndex[idx] = RiskStatus::INVALID_ADMIN;
        idx++;
        _toIndex[RiskStatus::INVALID_FEED] = idx;
        _fromIndex[idx] = RiskStatus::INVALID_FEED;
        idx++;
        _toIndex[RiskStatus::INVALID_MARKET] = idx;
        _fromIndex[idx] = RiskStatus::INVALID_MARKET;
        idx++;
        _toIndex[RiskStatus::INVALID_SETTLDATE] = idx;
        _fromIndex[idx] = RiskStatus::INVALID_SETTLDATE;
        idx++;
        _toIndex[RiskStatus::INVALID_AMOUNT] = idx;
        _fromIndex[idx] = RiskStatus::INVALID_AMOUNT;
        idx++;
        _toIndex[RiskStatus::INVALID_DROPCOPY_SEQID] = idx;
        _fromIndex[idx] = RiskStatus::INVALID_DROPCOPY_SEQID;
        idx++;
        _toIndex[RiskStatus::INVALID_DROPCOPY_FEED] = idx;
        _fromIndex[idx] = RiskStatus::INVALID_DROPCOPY_FEED;
        idx++;
        _toIndex[RiskStatus::MISSING_RISK_DATA] = idx;
        _fromIndex[idx] = RiskStatus::MISSING_RISK_DATA;
        idx++;

        _initialized = true;
    }

    void RiskStatus::finalizeEnum()
    {
    }

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

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

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

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

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

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

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

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