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

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

namespace MFAPI {

MDEntry::MDEntry()
{
}

MDEntry::~MDEntry()
{
}

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

    price = MFFloat(in->read_mffloat());
    amount = MFFloat(in->read_mffloat());
    minAmount = MFFloat(in->read_mffloat());
    updateAction = MDUpdateAction::Type(in->read_uint8());
    element = MDElement::Type(in->read_uint8());
    side = Side::Type(in->read_uint8());
    source = in->read_int8();
    numberOfOrders = in->read_int16();
    components = in->read_string();

}

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

    out->write_mffloat(price.toInt());
    out->write_mffloat(amount.toInt());
    out->write_mffloat(minAmount.toInt());
    out->write_uint8(updateAction); /* enum MDUpdateAction */
    out->write_uint8(element); /* enum MDElement */
    out->write_uint8(side); /* enum Side */
    out->write_int8(source);
    out->write_int16(numberOfOrders);
    out->write_string(components);

}

bool MDEntry::operator!=(const MDEntry& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(price != o.price) return true;
    if(amount != o.amount) return true;
    if(minAmount != o.minAmount) return true;
    if(updateAction != o.updateAction) return true;
    if(element != o.element) return true;
    if(side != o.side) return true;
    if(source != o.source) return true;
    if(numberOfOrders != o.numberOfOrders) return true;
    if(components != o.components) return true;

    return false;
}

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

bool MDEntry::operator<(const MDEntry& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(price < o.price) return true;
    else if(o.price < price) return false;
    if(amount < o.amount) return true;
    else if(o.amount < amount) return false;
    if(minAmount < o.minAmount) return true;
    else if(o.minAmount < minAmount) return false;
    if(updateAction < o.updateAction) return true;
    else if(o.updateAction < updateAction) return false;
    if(element < o.element) return true;
    else if(o.element < element) return false;
    if(side < o.side) return true;
    else if(o.side < side) return false;
    if(source < o.source) return true;
    else if(o.source < source) return false;
    if(numberOfOrders < o.numberOfOrders) return true;
    else if(o.numberOfOrders < numberOfOrders) return false;
    if(components < o.components) return true;
    else if(o.components < components) return false;

    return false;
}

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

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

void MDEntry::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("price=");
    out->write_int64(this->price.toInt());
    wr->newfield();
    out->write_data("amount=");
    out->write_int64(this->amount.toInt());
    wr->newfield();
    out->write_data("minAmount=");
    out->write_int64(this->minAmount.toInt());
    wr->newfield();
    out->write_data("updateAction=");
    out->write_rawfield(MDUpdateAction::toString(this->updateAction)); /* enum MDUpdateAction */
    wr->newfield();
    out->write_data("element=");
    out->write_rawfield(MDElement::toString(this->element)); /* enum MDElement */
    wr->newfield();
    out->write_data("side=");
    out->write_rawfield(Side::toString(this->side)); /* enum Side */
    wr->newfield();
    out->write_data("source=");
    out->write_int8(this->source);
    wr->newfield();
    out->write_data("numberOfOrders=");
    out->write_int16(this->numberOfOrders);
    wr->newfield();
    out->write_data("components=");
    out->write_string(this->components);

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