/**
 * Autogenerated by Thrift Compiler (0.13.0)
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
#include "Recursive_types.h"

#include <algorithm>
#include <ostream>

#include <thrift/TToString.h>




RecTree::~RecTree() noexcept {
}


void RecTree::__set_children(const std::vector<RecTree> & val) {
  this->children = val;
}

void RecTree::__set_item(const int16_t val) {
  this->item = val;
}
std::ostream& operator<<(std::ostream& out, const RecTree& obj)
{
  obj.printTo(out);
  return out;
}


uint32_t RecTree::read(::apache::thrift::protocol::TProtocol* iprot) {

  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
  uint32_t xfer = 0;
  std::string fname;
  ::apache::thrift::protocol::TType ftype;
  int16_t fid;

  xfer += iprot->readStructBegin(fname);

  using ::apache::thrift::protocol::TProtocolException;


  while (true)
  {
    xfer += iprot->readFieldBegin(fname, ftype, fid);
    if (ftype == ::apache::thrift::protocol::T_STOP) {
      break;
    }
    switch (fid)
    {
      case 1:
        if (ftype == ::apache::thrift::protocol::T_LIST) {
          {
            this->children.clear();
            uint32_t _size0;
            ::apache::thrift::protocol::TType _etype3;
            xfer += iprot->readListBegin(_etype3, _size0);
            this->children.resize(_size0);
            uint32_t _i4;
            for (_i4 = 0; _i4 < _size0; ++_i4)
            {
              xfer += this->children[_i4].read(iprot);
            }
            xfer += iprot->readListEnd();
          }
          this->__isset.children = true;
        } else {
          xfer += iprot->skip(ftype);
        }
        break;
      case 2:
        if (ftype == ::apache::thrift::protocol::T_I16) {
          xfer += iprot->readI16(this->item);
          this->__isset.item = true;
        } else {
          xfer += iprot->skip(ftype);
        }
        break;
      default:
        xfer += iprot->skip(ftype);
        break;
    }
    xfer += iprot->readFieldEnd();
  }

  xfer += iprot->readStructEnd();

  return xfer;
}

uint32_t RecTree::write(::apache::thrift::protocol::TProtocol* oprot) const {
  uint32_t xfer = 0;
  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
  xfer += oprot->writeStructBegin("RecTree");

  xfer += oprot->writeFieldBegin("children", ::apache::thrift::protocol::T_LIST, 1);
  {
    xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->children.size()));
    std::vector<RecTree> ::const_iterator _iter5;
    for (_iter5 = this->children.begin(); _iter5 != this->children.end(); ++_iter5)
    {
      xfer += (*_iter5).write(oprot);
    }
    xfer += oprot->writeListEnd();
  }
  xfer += oprot->writeFieldEnd();

  xfer += oprot->writeFieldBegin("item", ::apache::thrift::protocol::T_I16, 2);
  xfer += oprot->writeI16(this->item);
  xfer += oprot->writeFieldEnd();

  xfer += oprot->writeFieldStop();
  xfer += oprot->writeStructEnd();
  return xfer;
}

void swap(RecTree &a, RecTree &b) {
  using ::std::swap;
  swap(a.children, b.children);
  swap(a.item, b.item);
  swap(a.__isset, b.__isset);
}

RecTree::RecTree(const RecTree& other6) {
  children = other6.children;
  item = other6.item;
  __isset = other6.__isset;
}
RecTree& RecTree::operator=(const RecTree& other7) {
  children = other7.children;
  item = other7.item;
  __isset = other7.__isset;
  return *this;
}
void RecTree::printTo(std::ostream& out) const {
  using ::apache::thrift::to_string;
  out << "RecTree(";
  out << "children=" << to_string(children);
  out << ", " << "item=" << to_string(item);
  out << ")";
}


RecList::~RecList() noexcept {
}


void RecList::__set_nextitem(::std::shared_ptr<RecList> val) {
  this->nextitem = val;
}

void RecList::__set_item(const int16_t val) {
  this->item = val;
}
std::ostream& operator<<(std::ostream& out, const RecList& obj)
{
  obj.printTo(out);
  return out;
}


uint32_t RecList::read(::apache::thrift::protocol::TProtocol* iprot) {

  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
  uint32_t xfer = 0;
  std::string fname;
  ::apache::thrift::protocol::TType ftype;
  int16_t fid;

  xfer += iprot->readStructBegin(fname);

  using ::apache::thrift::protocol::TProtocolException;


  while (true)
  {
    xfer += iprot->readFieldBegin(fname, ftype, fid);
    if (ftype == ::apache::thrift::protocol::T_STOP) {
      break;
    }
    switch (fid)
    {
      case 1:
        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
          if (!this->nextitem) { 
            this->nextitem = ::std::shared_ptr<RecList>(new RecList);
          }
          xfer += this->nextitem->read(iprot);
          bool wasSet = false;
          if (this->nextitem->__isset.nextitem) { wasSet = true; }
          if (this->nextitem->__isset.item) { wasSet = true; }
          if (!wasSet) { this->nextitem.reset(); }
          this->__isset.nextitem = true;
        } else {
          xfer += iprot->skip(ftype);
        }
        break;
      case 3:
        if (ftype == ::apache::thrift::protocol::T_I16) {
          xfer += iprot->readI16(this->item);
          this->__isset.item = true;
        } else {
          xfer += iprot->skip(ftype);
        }
        break;
      default:
        xfer += iprot->skip(ftype);
        break;
    }
    xfer += iprot->readFieldEnd();
  }

  xfer += iprot->readStructEnd();

  return xfer;
}

uint32_t RecList::write(::apache::thrift::protocol::TProtocol* oprot) const {
  uint32_t xfer = 0;
  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
  xfer += oprot->writeStructBegin("RecList");

  xfer += oprot->writeFieldBegin("nextitem", ::apache::thrift::protocol::T_STRUCT, 1);
  if (this->nextitem) {
    xfer += this->nextitem->write(oprot); 
  } else {oprot->writeStructBegin("RecList"); 
    oprot->writeStructEnd();
    oprot->writeFieldStop();
  }
  xfer += oprot->writeFieldEnd();

  xfer += oprot->writeFieldBegin("item", ::apache::thrift::protocol::T_I16, 3);
  xfer += oprot->writeI16(this->item);
  xfer += oprot->writeFieldEnd();

  xfer += oprot->writeFieldStop();
  xfer += oprot->writeStructEnd();
  return xfer;
}

void swap(RecList &a, RecList &b) {
  using ::std::swap;
  swap(a.nextitem, b.nextitem);
  swap(a.item, b.item);
  swap(a.__isset, b.__isset);
}

RecList::RecList(const RecList& other8) {
  nextitem = other8.nextitem;
  item = other8.item;
  __isset = other8.__isset;
}
RecList& RecList::operator=(const RecList& other9) {
  nextitem = other9.nextitem;
  item = other9.item;
  __isset = other9.__isset;
  return *this;
}
void RecList::printTo(std::ostream& out) const {
  using ::apache::thrift::to_string;
  out << "RecList(";
  out << "nextitem=" << to_string(nextitem);
  out << ", " << "item=" << to_string(item);
  out << ")";
}


CoRec::~CoRec() noexcept {
}


void CoRec::__set_other(::std::shared_ptr<CoRec2> val) {
  this->other = val;
}
std::ostream& operator<<(std::ostream& out, const CoRec& obj)
{
  obj.printTo(out);
  return out;
}


uint32_t CoRec::read(::apache::thrift::protocol::TProtocol* iprot) {

  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
  uint32_t xfer = 0;
  std::string fname;
  ::apache::thrift::protocol::TType ftype;
  int16_t fid;

  xfer += iprot->readStructBegin(fname);

  using ::apache::thrift::protocol::TProtocolException;


  while (true)
  {
    xfer += iprot->readFieldBegin(fname, ftype, fid);
    if (ftype == ::apache::thrift::protocol::T_STOP) {
      break;
    }
    switch (fid)
    {
      case 1:
        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
          if (!this->other) { 
            this->other = ::std::shared_ptr<CoRec2>(new CoRec2);
          }
          xfer += this->other->read(iprot);
          bool wasSet = false;
          if (this->other->__isset.other) { wasSet = true; }
          if (!wasSet) { this->other.reset(); }
          this->__isset.other = true;
        } else {
          xfer += iprot->skip(ftype);
        }
        break;
      default:
        xfer += iprot->skip(ftype);
        break;
    }
    xfer += iprot->readFieldEnd();
  }

  xfer += iprot->readStructEnd();

  return xfer;
}

uint32_t CoRec::write(::apache::thrift::protocol::TProtocol* oprot) const {
  uint32_t xfer = 0;
  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
  xfer += oprot->writeStructBegin("CoRec");

  xfer += oprot->writeFieldBegin("other", ::apache::thrift::protocol::T_STRUCT, 1);
  if (this->other) {
    xfer += this->other->write(oprot); 
  } else {oprot->writeStructBegin("CoRec2"); 
    oprot->writeStructEnd();
    oprot->writeFieldStop();
  }
  xfer += oprot->writeFieldEnd();

  xfer += oprot->writeFieldStop();
  xfer += oprot->writeStructEnd();
  return xfer;
}

void swap(CoRec &a, CoRec &b) {
  using ::std::swap;
  swap(a.other, b.other);
  swap(a.__isset, b.__isset);
}

CoRec::CoRec(const CoRec& other10) {
  other = other10.other;
  __isset = other10.__isset;
}
CoRec& CoRec::operator=(const CoRec& other11) {
  other = other11.other;
  __isset = other11.__isset;
  return *this;
}
void CoRec::printTo(std::ostream& out) const {
  using ::apache::thrift::to_string;
  out << "CoRec(";
  out << "other=" << to_string(other);
  out << ")";
}


CoRec2::~CoRec2() noexcept {
}


void CoRec2::__set_other(const CoRec& val) {
  this->other = val;
}
std::ostream& operator<<(std::ostream& out, const CoRec2& obj)
{
  obj.printTo(out);
  return out;
}


uint32_t CoRec2::read(::apache::thrift::protocol::TProtocol* iprot) {

  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
  uint32_t xfer = 0;
  std::string fname;
  ::apache::thrift::protocol::TType ftype;
  int16_t fid;

  xfer += iprot->readStructBegin(fname);

  using ::apache::thrift::protocol::TProtocolException;


  while (true)
  {
    xfer += iprot->readFieldBegin(fname, ftype, fid);
    if (ftype == ::apache::thrift::protocol::T_STOP) {
      break;
    }
    switch (fid)
    {
      case 1:
        if (ftype == ::apache::thrift::protocol::T_STRUCT) {
          xfer += this->other.read(iprot);
          this->__isset.other = true;
        } else {
          xfer += iprot->skip(ftype);
        }
        break;
      default:
        xfer += iprot->skip(ftype);
        break;
    }
    xfer += iprot->readFieldEnd();
  }

  xfer += iprot->readStructEnd();

  return xfer;
}

uint32_t CoRec2::write(::apache::thrift::protocol::TProtocol* oprot) const {
  uint32_t xfer = 0;
  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
  xfer += oprot->writeStructBegin("CoRec2");

  xfer += oprot->writeFieldBegin("other", ::apache::thrift::protocol::T_STRUCT, 1);
  xfer += this->other.write(oprot);
  xfer += oprot->writeFieldEnd();

  xfer += oprot->writeFieldStop();
  xfer += oprot->writeStructEnd();
  return xfer;
}

void swap(CoRec2 &a, CoRec2 &b) {
  using ::std::swap;
  swap(a.other, b.other);
  swap(a.__isset, b.__isset);
}

CoRec2::CoRec2(const CoRec2& other12) {
  other = other12.other;
  __isset = other12.__isset;
}
CoRec2& CoRec2::operator=(const CoRec2& other13) {
  other = other13.other;
  __isset = other13.__isset;
  return *this;
}
void CoRec2::printTo(std::ostream& out) const {
  using ::apache::thrift::to_string;
  out << "CoRec2(";
  out << "other=" << to_string(other);
  out << ")";
}


VectorTest::~VectorTest() noexcept {
}


void VectorTest::__set_lister(const std::vector<RecList> & val) {
  this->lister = val;
}
std::ostream& operator<<(std::ostream& out, const VectorTest& obj)
{
  obj.printTo(out);
  return out;
}


uint32_t VectorTest::read(::apache::thrift::protocol::TProtocol* iprot) {

  ::apache::thrift::protocol::TInputRecursionTracker tracker(*iprot);
  uint32_t xfer = 0;
  std::string fname;
  ::apache::thrift::protocol::TType ftype;
  int16_t fid;

  xfer += iprot->readStructBegin(fname);

  using ::apache::thrift::protocol::TProtocolException;


  while (true)
  {
    xfer += iprot->readFieldBegin(fname, ftype, fid);
    if (ftype == ::apache::thrift::protocol::T_STOP) {
      break;
    }
    switch (fid)
    {
      case 1:
        if (ftype == ::apache::thrift::protocol::T_LIST) {
          {
            this->lister.clear();
            uint32_t _size14;
            ::apache::thrift::protocol::TType _etype17;
            xfer += iprot->readListBegin(_etype17, _size14);
            this->lister.resize(_size14);
            uint32_t _i18;
            for (_i18 = 0; _i18 < _size14; ++_i18)
            {
              xfer += this->lister[_i18].read(iprot);
            }
            xfer += iprot->readListEnd();
          }
          this->__isset.lister = true;
        } else {
          xfer += iprot->skip(ftype);
        }
        break;
      default:
        xfer += iprot->skip(ftype);
        break;
    }
    xfer += iprot->readFieldEnd();
  }

  xfer += iprot->readStructEnd();

  return xfer;
}

uint32_t VectorTest::write(::apache::thrift::protocol::TProtocol* oprot) const {
  uint32_t xfer = 0;
  ::apache::thrift::protocol::TOutputRecursionTracker tracker(*oprot);
  xfer += oprot->writeStructBegin("VectorTest");

  xfer += oprot->writeFieldBegin("lister", ::apache::thrift::protocol::T_LIST, 1);
  {
    xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRUCT, static_cast<uint32_t>(this->lister.size()));
    std::vector<RecList> ::const_iterator _iter19;
    for (_iter19 = this->lister.begin(); _iter19 != this->lister.end(); ++_iter19)
    {
      xfer += (*_iter19).write(oprot);
    }
    xfer += oprot->writeListEnd();
  }
  xfer += oprot->writeFieldEnd();

  xfer += oprot->writeFieldStop();
  xfer += oprot->writeStructEnd();
  return xfer;
}

void swap(VectorTest &a, VectorTest &b) {
  using ::std::swap;
  swap(a.lister, b.lister);
  swap(a.__isset, b.__isset);
}

VectorTest::VectorTest(const VectorTest& other20) {
  lister = other20.lister;
  __isset = other20.__isset;
}
VectorTest& VectorTest::operator=(const VectorTest& other21) {
  lister = other21.lister;
  __isset = other21.__isset;
  return *this;
}
void VectorTest::printTo(std::ostream& out) const {
  using ::apache::thrift::to_string;
  out << "VectorTest(";
  out << "lister=" << to_string(lister);
  out << ")";
}


