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

#include <API/Clients/CPP/Proto/TradeLimitData.h>
#include <API/Clients/CPP/MFAPIClient/APIPrivate.h>

namespace MFAPI {

TradeLimitData::TradeLimitData()
{
}

TradeLimitData::~TradeLimitData()
{
}

void TradeLimitData::read(void* v)
{
    FastCodec* in = static_cast<FastCodec*>(v);
    (void)in;

    clDataID = in->read_string();
    {
        const uint16_t len = in->read_length();
        groupLimits.resize(len);
        std::vector<TradeLimit>::iterator it = groupLimits.begin();
        for ( ; it != groupLimits.end(); ++it ) {
            it->read(v);
        }
    }
    {
        const uint16_t len = in->read_length();
        groupStates.resize(len);
        std::vector<TradeState>::iterator it = groupStates.begin();
        for ( ; it != groupStates.end(); ++it ) {
            it->read(v);
        }
    }
    {
        const uint16_t len = in->read_length();
        userHierarchy.resize(len);
        std::vector<TradeHierarchy>::iterator it = userHierarchy.begin();
        for ( ; it != userHierarchy.end(); ++it ) {
            it->read(v);
        }
    }
    {
        const uint16_t len = in->read_length();
        marketRates.resize(len);
        std::vector<MarketRate>::iterator it = marketRates.begin();
        for ( ; it != marketRates.end(); ++it ) {
            it->read(v);
        }
    }
    numRemainingMessages = in->read_int32();
    isSnapshot = in->read_bool();

}

void TradeLimitData::write(void* v) const
{
    FastCodec* out = static_cast<FastCodec*>(v);
    (void)out;

    out->write_string(clDataID);
    {
        out->write_length(groupLimits.size());
        std::vector<TradeLimit>::const_iterator it = groupLimits.begin();
        for ( ; it != groupLimits.end(); ++it ) {
            it->write(v);
        }
    }
    {
        out->write_length(groupStates.size());
        std::vector<TradeState>::const_iterator it = groupStates.begin();
        for ( ; it != groupStates.end(); ++it ) {
            it->write(v);
        }
    }
    {
        out->write_length(userHierarchy.size());
        std::vector<TradeHierarchy>::const_iterator it = userHierarchy.begin();
        for ( ; it != userHierarchy.end(); ++it ) {
            it->write(v);
        }
    }
    {
        out->write_length(marketRates.size());
        std::vector<MarketRate>::const_iterator it = marketRates.begin();
        for ( ; it != marketRates.end(); ++it ) {
            it->write(v);
        }
    }
    out->write_int32(numRemainingMessages);
    out->write_bool(isSnapshot);

}

bool TradeLimitData::operator!=(const TradeLimitData& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(clDataID != o.clDataID) return true;
    if(groupLimits != o.groupLimits) return true;
    if(groupStates != o.groupStates) return true;
    if(userHierarchy != o.userHierarchy) return true;
    if(marketRates != o.marketRates) return true;
    if(numRemainingMessages != o.numRemainingMessages) return true;
    if(isSnapshot != o.isSnapshot) return true;

    return false;
}

bool TradeLimitData::operator==(const TradeLimitData& o) const
{
    return !operator!=(o);
}

bool TradeLimitData::operator<(const TradeLimitData& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(clDataID < o.clDataID) return true;
    else if(o.clDataID < clDataID) return false;
    if(groupLimits < o.groupLimits) return true;
    else if(o.groupLimits < groupLimits) return false;
    if(groupStates < o.groupStates) return true;
    else if(o.groupStates < groupStates) return false;
    if(userHierarchy < o.userHierarchy) return true;
    else if(o.userHierarchy < userHierarchy) return false;
    if(marketRates < o.marketRates) return true;
    else if(o.marketRates < marketRates) return false;
    if(numRemainingMessages < o.numRemainingMessages) return true;
    else if(o.numRemainingMessages < numRemainingMessages) return false;
    if(isSnapshot < o.isSnapshot) return true;
    else if(o.isSnapshot < isSnapshot) return false;

    return false;
}

std::ostream& operator<<(std::ostream& os, const TradeLimitData& o)
{
    o.dump(os, false);
    return os;
}

void TradeLimitData::dump(std::ostream& os, bool pretty) const
{
    TextStream sos;
    TextCodec codec(sos);
    TextWriter wr(codec, true);
    sos << "<TradeLimitData ";
    dump(&wr);
    sos << ">";
    os.write(sos.ends(), sos.size());
}

void TradeLimitData::dump(void* v) const
{
    TextWriter* wr = static_cast<TextWriter*>(v);
    TextCodec* out = &wr->out();
    (void)wr;

    TextWriter::State __state = wr->push("(", false);
    wr->newfield();
    out->write_data("clDataID=");
    out->write_string(this->clDataID);
    wr->newfield();
    out->write_data("groupLimits=");

    {
        TextWriter::State __state = wr->push("[", false);
        std::vector<TradeLimit>::const_iterator it = this->groupLimits.begin();
        std::vector<TradeLimit>::const_iterator end__groupLimits = this->groupLimits.end();
        for ( ; it != end__groupLimits; ++it ) {
            wr->newfield();
            it->dump(v);
        }
        wr->pop("]", __state);
    }

    wr->newfield();
    out->write_data("groupStates=");

    {
        TextWriter::State __state = wr->push("[", false);
        std::vector<TradeState>::const_iterator it = this->groupStates.begin();
        std::vector<TradeState>::const_iterator end__groupStates = this->groupStates.end();
        for ( ; it != end__groupStates; ++it ) {
            wr->newfield();
            it->dump(v);
        }
        wr->pop("]", __state);
    }

    wr->newfield();
    out->write_data("userHierarchy=");

    {
        TextWriter::State __state = wr->push("[", false);
        std::vector<TradeHierarchy>::const_iterator it = this->userHierarchy.begin();
        std::vector<TradeHierarchy>::const_iterator end__userHierarchy = this->userHierarchy.end();
        for ( ; it != end__userHierarchy; ++it ) {
            wr->newfield();
            it->dump(v);
        }
        wr->pop("]", __state);
    }

    wr->newfield();
    out->write_data("marketRates=");

    {
        TextWriter::State __state = wr->push("[", false);
        std::vector<MarketRate>::const_iterator it = this->marketRates.begin();
        std::vector<MarketRate>::const_iterator end__marketRates = this->marketRates.end();
        for ( ; it != end__marketRates; ++it ) {
            wr->newfield();
            it->dump(v);
        }
        wr->pop("]", __state);
    }

    wr->newfield();
    out->write_data("numRemainingMessages=");
    out->write_int32(this->numRemainingMessages);
    wr->newfield();
    out->write_data("isSnapshot=");
    out->write_bool(this->isSnapshot);

    wr->pop(")", __state);
}

} // 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 
*/
