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

#include <algorithm>
#include <ostream>

#include <thrift/TToString.h>

namespace thrift_test {


Record::~Record() throw() {
}


void Record::__set_ids(const std::vector<int64_t> & val) {
  this->ids = val;
}

void Record::__set_strings(const std::vector<std::string> & val) {
  this->strings = val;
}
std::ostream& operator<<(std::ostream& out, const Record& obj)
{
  obj.printTo(out);
  return out;
}


uint32_t Record::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;

  bool isset_ids = false;
  bool isset_strings = false;

  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->ids.clear();
            uint32_t _size0;
            ::apache::thrift::protocol::TType _etype3;
            xfer += iprot->readListBegin(_etype3, _size0);
            this->ids.resize(_size0);
            uint32_t _i4;
            for (_i4 = 0; _i4 < _size0; ++_i4)
            {
              xfer += iprot->readI64(this->ids[_i4]);
            }
            xfer += iprot->readListEnd();
          }
          isset_ids = true;
        } else {
          xfer += iprot->skip(ftype);
        }
        break;
      case 2:
        if (ftype == ::apache::thrift::protocol::T_LIST) {
          {
            this->strings.clear();
            uint32_t _size5;
            ::apache::thrift::protocol::TType _etype8;
            xfer += iprot->readListBegin(_etype8, _size5);
            this->strings.resize(_size5);
            uint32_t _i9;
            for (_i9 = 0; _i9 < _size5; ++_i9)
            {
              xfer += iprot->readString(this->strings[_i9]);
            }
            xfer += iprot->readListEnd();
          }
          isset_strings = true;
        } else {
          xfer += iprot->skip(ftype);
        }
        break;
      default:
        xfer += iprot->skip(ftype);
        break;
    }
    xfer += iprot->readFieldEnd();
  }

  xfer += iprot->readStructEnd();

  if (!isset_ids)
    throw TProtocolException(TProtocolException::INVALID_DATA);
  if (!isset_strings)
    throw TProtocolException(TProtocolException::INVALID_DATA);
  return xfer;
}

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

  xfer += oprot->writeFieldBegin("ids", ::apache::thrift::protocol::T_LIST, 1);
  {
    xfer += oprot->writeListBegin(::apache::thrift::protocol::T_I64, static_cast<uint32_t>(this->ids.size()));
    std::vector<int64_t> ::const_iterator _iter10;
    for (_iter10 = this->ids.begin(); _iter10 != this->ids.end(); ++_iter10)
    {
      xfer += oprot->writeI64((*_iter10));
    }
    xfer += oprot->writeListEnd();
  }
  xfer += oprot->writeFieldEnd();

  xfer += oprot->writeFieldBegin("strings", ::apache::thrift::protocol::T_LIST, 2);
  {
    xfer += oprot->writeListBegin(::apache::thrift::protocol::T_STRING, static_cast<uint32_t>(this->strings.size()));
    std::vector<std::string> ::const_iterator _iter11;
    for (_iter11 = this->strings.begin(); _iter11 != this->strings.end(); ++_iter11)
    {
      xfer += oprot->writeString((*_iter11));
    }
    xfer += oprot->writeListEnd();
  }
  xfer += oprot->writeFieldEnd();

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

void swap(Record &a, Record &b) {
  using ::std::swap;
  swap(a.ids, b.ids);
  swap(a.strings, b.strings);
}

Record::Record(const Record& other12) {
  ids = other12.ids;
  strings = other12.strings;
}
Record& Record::operator=(const Record& other13) {
  ids = other13.ids;
  strings = other13.strings;
  return *this;
}
void Record::printTo(std::ostream& out) const {
  using ::apache::thrift::to_string;
  out << "Record(";
  out << "ids=" << to_string(ids);
  out << ", " << "strings=" << to_string(strings);
  out << ")";
}

} // namespace
