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

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

namespace MFAPI {

OrderReceived::OrderReceived()
{
}

OrderReceived::~OrderReceived()
{
}

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

    sequenceID = in->read_int32();
    orderID = in->read_int64();
    clOrdID = in->read_string();
    modelID = in->read_string();
    timeApiServer = in->read_int64();
    timeApiClient = in->read_int64();
    feedID = in->read_int32();
    marketID = in->read_int32();
    side = Side::Type(in->read_uint8());
    amount = MFFloat(in->read_mffloat());
    price = MFFloat(in->read_mffloat());
    ordType = OrderType::Type(in->read_uint8());
    timeInForce = TimeInForce::Type(in->read_uint8());

}

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

    out->write_int32(sequenceID);
    out->write_int64(orderID);
    out->write_string(clOrdID);
    out->write_string(modelID);
    out->write_int64(timeApiServer);
    out->write_int64(timeApiClient);
    out->write_int32(feedID);
    out->write_int32(marketID);
    out->write_uint8(side); /* enum Side */
    out->write_mffloat(amount.toInt());
    out->write_mffloat(price.toInt());
    out->write_uint8(ordType); /* enum OrderType */
    out->write_uint8(timeInForce); /* enum TimeInForce */

}

bool OrderReceived::operator!=(const OrderReceived& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(sequenceID != o.sequenceID) return true;
    if(orderID != o.orderID) return true;
    if(clOrdID != o.clOrdID) return true;
    if(modelID != o.modelID) return true;
    if(timeApiServer != o.timeApiServer) return true;
    if(timeApiClient != o.timeApiClient) return true;
    if(feedID != o.feedID) return true;
    if(marketID != o.marketID) return true;
    if(side != o.side) return true;
    if(amount != o.amount) return true;
    if(price != o.price) return true;
    if(ordType != o.ordType) return true;
    if(timeInForce != o.timeInForce) return true;

    return false;
}

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

bool OrderReceived::operator<(const OrderReceived& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(sequenceID < o.sequenceID) return true;
    else if(o.sequenceID < sequenceID) return false;
    if(orderID < o.orderID) return true;
    else if(o.orderID < orderID) return false;
    if(clOrdID < o.clOrdID) return true;
    else if(o.clOrdID < clOrdID) return false;
    if(modelID < o.modelID) return true;
    else if(o.modelID < modelID) return false;
    if(timeApiServer < o.timeApiServer) return true;
    else if(o.timeApiServer < timeApiServer) return false;
    if(timeApiClient < o.timeApiClient) return true;
    else if(o.timeApiClient < timeApiClient) return false;
    if(feedID < o.feedID) return true;
    else if(o.feedID < feedID) return false;
    if(marketID < o.marketID) return true;
    else if(o.marketID < marketID) return false;
    if(side < o.side) return true;
    else if(o.side < side) return false;
    if(amount < o.amount) return true;
    else if(o.amount < amount) return false;
    if(price < o.price) return true;
    else if(o.price < price) return false;
    if(ordType < o.ordType) return true;
    else if(o.ordType < ordType) return false;
    if(timeInForce < o.timeInForce) return true;
    else if(o.timeInForce < timeInForce) return false;

    return false;
}

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

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

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

    TextWriter::State __state = wr->push("(", true);
    wr->newfield();
    out->write_data("sequenceID=");
    out->write_int32(this->sequenceID);
    wr->newfield();
    out->write_data("orderID=");
    out->write_int64(this->orderID);
    wr->newfield();
    out->write_data("clOrdID=");
    out->write_string(this->clOrdID);
    wr->newfield();
    out->write_data("modelID=");
    out->write_string(this->modelID);
    wr->newfield();
    out->write_data("timeApiServer=");
    out->write_int64(this->timeApiServer);
    wr->newfield();
    out->write_data("timeApiClient=");
    out->write_int64(this->timeApiClient);
    wr->newfield();
    out->write_data("feedID=");
    out->write_int32(this->feedID);
    wr->newfield();
    out->write_data("marketID=");
    out->write_int32(this->marketID);
    wr->newfield();
    out->write_data("side=");
    out->write_rawfield(Side::toString(this->side)); /* enum Side */
    wr->newfield();
    out->write_data("amount=");
    out->write_int64(this->amount.toInt());
    wr->newfield();
    out->write_data("price=");
    out->write_int64(this->price.toInt());
    wr->newfield();
    out->write_data("ordType=");
    out->write_rawfield(OrderType::toString(this->ordType)); /* enum OrderType */
    wr->newfield();
    out->write_data("timeInForce=");
    out->write_rawfield(TimeInForce::toString(this->timeInForce)); /* enum TimeInForce */

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