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

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

namespace MFAPI {

APIFeed::APIFeed()
{
}

APIFeed::~APIFeed()
{
}

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

    name = in->read_string();
    exchangeName = in->read_string();
    feedID = in->read_int32();
    flags = in->read_int64();
    {
        const uint16_t len = in->read_length();
        marketList.resize(len);
        std::vector<APIMarket>::iterator it = marketList.begin();
        for ( ; it != marketList.end(); ++it ) {
            it->read(v);
        }
    }

}

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

    out->write_string(name);
    out->write_string(exchangeName);
    out->write_int32(feedID);
    out->write_int64(flags);
    {
        out->write_length(marketList.size());
        std::vector<APIMarket>::const_iterator it = marketList.begin();
        for ( ; it != marketList.end(); ++it ) {
            it->write(v);
        }
    }

}

bool APIFeed::operator!=(const APIFeed& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(name != o.name) return true;
    if(exchangeName != o.exchangeName) return true;
    if(feedID != o.feedID) return true;
    if(flags != o.flags) return true;
    if(marketList != o.marketList) return true;

    return false;
}

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

bool APIFeed::operator<(const APIFeed& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(name < o.name) return true;
    else if(o.name < name) return false;
    if(exchangeName < o.exchangeName) return true;
    else if(o.exchangeName < exchangeName) return false;
    if(feedID < o.feedID) return true;
    else if(o.feedID < feedID) return false;
    if(flags < o.flags) return true;
    else if(o.flags < flags) return false;
    if(marketList < o.marketList) return true;
    else if(o.marketList < marketList) return false;

    return false;
}

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

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

void APIFeed::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("name=");
    out->write_string(this->name);
    wr->newfield();
    out->write_data("exchangeName=");
    out->write_string(this->exchangeName);
    wr->newfield();
    out->write_data("feedID=");
    out->write_int32(this->feedID);
    wr->newfield();
    out->write_data("flags=");
    out->write_int64(this->flags);
    wr->newfield();
    out->write_data("marketList=");

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

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