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

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

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

namespace MFAPI {

using namespace std;

// StandardTenor {

    bool StandardTenor::_initialized = false;

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

    const unsigned int StandardTenor::_maxValue = 26;
    const unsigned int StandardTenor::_nbValues = 26;

    const char* StandardTenor::_names[26];
    unsigned char StandardTenor::_toIndex[26];
    StandardTenor::Type StandardTenor::_fromIndex[26];

    void StandardTenor::initializeEnum()
    {
        const char* dummy = 0;
        std::fill_n(_names, 26, dummy);
        _names[NA] = "NA";
        _names[TOD] = "TOD";
        _names[TOM] = "TOM";
        _names[ON] = "ON";
        _names[TN] = "TN";
        _names[SP] = "SP";
        _names[SN] = "SN";
        _names[W1] = "W1";
        _names[W2] = "W2";
        _names[W3] = "W3";
        _names[M1] = "M1";
        _names[M2] = "M2";
        _names[M3] = "M3";
        _names[M4] = "M4";
        _names[M5] = "M5";
        _names[M6] = "M6";
        _names[M7] = "M7";
        _names[M8] = "M8";
        _names[M9] = "M9";
        _names[M10] = "M10";
        _names[M11] = "M11";
        _names[Y1] = "Y1";
        _names[M15] = "M15";
        _names[M18] = "M18";
        _names[M21] = "M21";
        _names[Y2] = "Y2";

        unsigned char idx = 0;
        _toIndex[StandardTenor::NA] = idx;
        _fromIndex[idx] = StandardTenor::NA;
        idx++;
        _toIndex[StandardTenor::TOD] = idx;
        _fromIndex[idx] = StandardTenor::TOD;
        idx++;
        _toIndex[StandardTenor::TOM] = idx;
        _fromIndex[idx] = StandardTenor::TOM;
        idx++;
        _toIndex[StandardTenor::ON] = idx;
        _fromIndex[idx] = StandardTenor::ON;
        idx++;
        _toIndex[StandardTenor::TN] = idx;
        _fromIndex[idx] = StandardTenor::TN;
        idx++;
        _toIndex[StandardTenor::SP] = idx;
        _fromIndex[idx] = StandardTenor::SP;
        idx++;
        _toIndex[StandardTenor::SN] = idx;
        _fromIndex[idx] = StandardTenor::SN;
        idx++;
        _toIndex[StandardTenor::W1] = idx;
        _fromIndex[idx] = StandardTenor::W1;
        idx++;
        _toIndex[StandardTenor::W2] = idx;
        _fromIndex[idx] = StandardTenor::W2;
        idx++;
        _toIndex[StandardTenor::W3] = idx;
        _fromIndex[idx] = StandardTenor::W3;
        idx++;
        _toIndex[StandardTenor::M1] = idx;
        _fromIndex[idx] = StandardTenor::M1;
        idx++;
        _toIndex[StandardTenor::M2] = idx;
        _fromIndex[idx] = StandardTenor::M2;
        idx++;
        _toIndex[StandardTenor::M3] = idx;
        _fromIndex[idx] = StandardTenor::M3;
        idx++;
        _toIndex[StandardTenor::M4] = idx;
        _fromIndex[idx] = StandardTenor::M4;
        idx++;
        _toIndex[StandardTenor::M5] = idx;
        _fromIndex[idx] = StandardTenor::M5;
        idx++;
        _toIndex[StandardTenor::M6] = idx;
        _fromIndex[idx] = StandardTenor::M6;
        idx++;
        _toIndex[StandardTenor::M7] = idx;
        _fromIndex[idx] = StandardTenor::M7;
        idx++;
        _toIndex[StandardTenor::M8] = idx;
        _fromIndex[idx] = StandardTenor::M8;
        idx++;
        _toIndex[StandardTenor::M9] = idx;
        _fromIndex[idx] = StandardTenor::M9;
        idx++;
        _toIndex[StandardTenor::M10] = idx;
        _fromIndex[idx] = StandardTenor::M10;
        idx++;
        _toIndex[StandardTenor::M11] = idx;
        _fromIndex[idx] = StandardTenor::M11;
        idx++;
        _toIndex[StandardTenor::Y1] = idx;
        _fromIndex[idx] = StandardTenor::Y1;
        idx++;
        _toIndex[StandardTenor::M15] = idx;
        _fromIndex[idx] = StandardTenor::M15;
        idx++;
        _toIndex[StandardTenor::M18] = idx;
        _fromIndex[idx] = StandardTenor::M18;
        idx++;
        _toIndex[StandardTenor::M21] = idx;
        _fromIndex[idx] = StandardTenor::M21;
        idx++;
        _toIndex[StandardTenor::Y2] = idx;
        _fromIndex[idx] = StandardTenor::Y2;
        idx++;

        _initialized = true;
    }

    void StandardTenor::finalizeEnum()
    {
    }

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

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

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

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

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

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

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

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