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

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

namespace MFAPI {

TradeHierarchy::TradeHierarchy()
{
}

TradeHierarchy::~TradeHierarchy()
{
}

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

    userName = in->read_string();
    {
        const uint16_t len = in->read_length();
        groupNames.resize(len);
        std::vector<std::string>::iterator it = groupNames.begin();
        for ( ; it != groupNames.end(); ++it ) {
            *it = in->read_string();
        }
    }

}

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

    out->write_string(userName);
    {
        out->write_length(groupNames.size());
        std::vector<std::string>::const_iterator it = groupNames.begin();
        for ( ; it != groupNames.end(); ++it ) {
            out->write_string(*it);
        }
    }

}

bool TradeHierarchy::operator!=(const TradeHierarchy& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(userName != o.userName) return true;
    if(groupNames != o.groupNames) return true;

    return false;
}

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

bool TradeHierarchy::operator<(const TradeHierarchy& o) const
{
    if(this == &o)
    {
        return false;
    }
    if(userName < o.userName) return true;
    else if(o.userName < userName) return false;
    if(groupNames < o.groupNames) return true;
    else if(o.groupNames < groupNames) return false;

    return false;
}

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

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

void TradeHierarchy::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("userName=");
    out->write_string(this->userName);
    wr->newfield();
    out->write_data("groupNames=");

    {
        TextWriter::State __state = wr->push("[", false);
        std::vector<std::string>::const_iterator it = this->groupNames.begin();
        std::vector<std::string>::const_iterator end__groupNames = this->groupNames.end();
        for ( ; it != end__groupNames; ++it ) {
            wr->newfield();
            out->write_string(*it);
        }
        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 
*/
