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

#ifndef __MFAPIGEN_APIRESULT__
#define __MFAPIGEN_APIRESULT__

#include <iostream>

namespace MFAPI {

/** (Enum) Result/error codes provided by the API methods.
 */

struct APIResult
{
    enum Type {
    OK = 0,
    COULD_NOT_CONNECT = 10,
    TIMEOUT = 11,
    BUFFER_FULL = 12,
    COULD_NOT_OPEN = 14,
    SOCKERR_DNS = 101,
    SOCKERR_CREATE = 102,
    SOCKERR_CONNECT = 103,
    SOCKERR_CLOSED = 104,
    SOCKERR_READING = 105,
    SOCKERR_WRITING = 106,
    NOT_CONNECTED = 20,
    NOT_RUNNING = 21,
    IS_CONNECTED = 22,
    IS_RUNNING = 23,
    IS_STOPPING = 24,
    EXCEPTION_THROWN = 25,
    PROTOCOL_ERROR = 30,
    INCOMPATIBLE_PROTOCOL = 31,
    INVALID_USER = 32,
    INVALID_PASSWORD = 33,
    USER_ALREADY_CONNECTED = 34,
    COULD_NOT_LOGIN = 35,
    INVALID_FEED = 40,
    INVALID_MARKET = 41,
    INVALID_ORDERID = 42,
    INVALID_BATCHID = 43,
    INVALID_CLIENT_ORDERID = 44,
    DUPLICATE_CLIENT_ORDERID = 45,
    INVALID_MARKETDATA_FEED = 46,
    INVALID_TRADING_FEED = 47,
    USER_LOCKED = 48,
    SYSTEM_LOCKED = 49,
    ADMIN_HANDLER_FAULT = 50,
    INVALID_PARAMETER = 252,
    NOT_IMPLEMENTED = 253,
    NOT_APPLICABLE = 254
    };

    static const char* Name;

    static void initializeEnum();
    static void finalizeEnum();

    static bool isValid( unsigned char iv );

    // Convert from an emum to various other things.
    static unsigned char toValue( Type iv );
    static const char* toString( unsigned char iv );
    static unsigned char toIndex( Type );

    // Convert from various other things to an enum.
    static Type fromValue( unsigned char iv );
    static Type fromIndex( unsigned char index );
    static Type fromString( const char* );

private:
    static bool _initialized;
    static const unsigned int _maxValue;
    static const unsigned int _nbValues;

    static const char* _names[255];
    static unsigned char _toIndex[255];
    static Type _fromIndex[37];

};

std::ostream& operator<<( std::ostream& os, APIResult::Type en );

} // MFAPI

#endif
// InclKwds: APIResult
