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

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

namespace MFAPI {

MktDataMessage::MktDataMessage()
{
}

MktDataMessage::~MktDataMessage()
{
}

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

    mvd.read(v);
    {
        const uint16_t len = in->read_length();
        fmIDsInBatch.resize(len);
        std::vector<FeedMarketID>::iterator it = fmIDsInBatch.begin();
        for ( ; it != fmIDsInBatch.end(); ++it ) {
            it->read(v);
        }
    }
    batchID = in->read_int64();
    streamID = in->read_int32();

}

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

    mvd.write(v);
    {
        out->write_length(fmIDsInBatch.size());
        std::vector<FeedMarketID>::const_iterator it = fmIDsInBatch.begin();
        for ( ; it != fmIDsInBatch.end(); ++it ) {
            it->write(v);
        }
    }
    out->write_int64(batchID);
    out->write_int32(streamID);

}

bool MktDataMessage::operator!=(const MktDataMessage& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(mvd != o.mvd) return true;
    if(fmIDsInBatch != o.fmIDsInBatch) return true;
    if(batchID != o.batchID) return true;
    if(streamID != o.streamID) return true;

    return false;
}

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

bool MktDataMessage::operator<(const MktDataMessage& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(mvd < o.mvd) return true;
    else if(o.mvd < mvd) return false;
    if(fmIDsInBatch < o.fmIDsInBatch) return true;
    else if(o.fmIDsInBatch < fmIDsInBatch) return false;
    if(batchID < o.batchID) return true;
    else if(o.batchID < batchID) return false;
    if(streamID < o.streamID) return true;
    else if(o.streamID < streamID) return false;

    return false;
}

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

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

void MktDataMessage::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("mvd=");
    this->mvd.dump(v);
    wr->newfield();
    out->write_data("fmIDsInBatch=");

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

    wr->newfield();
    out->write_data("batchID=");
    out->write_int64(this->batchID);
    wr->newfield();
    out->write_data("streamID=");
    out->write_int32(this->streamID);

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