/**
 * Autogenerated by Thrift
 *
 * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
 *  @generated
 */
#include "module2_types.h"

#include "module2_reflection.h"

#include <algorithm>
#include <string.h>



const uint64_t StructUsingOtherNamespace::_reflection_id;
void StructUsingOtherNamespace::_reflection_register(::apache::thrift::reflection::Schema& schema) {
   ::module2_reflection_::reflectionInitializer_8285996275179549516(schema);
}

StructUsingOtherNamespace::StructUsingOtherNamespace(const StructUsingOtherNamespace& src0) {
  if (src0.other)
    other.reset(new  ::cpp1::Included(*src0.other));
}
bool StructUsingOtherNamespace::operator == (const StructUsingOtherNamespace & rhs) const {
  if (bool(other) != bool(rhs.other))
    return false;
  else if (bool(other) && !(*other == *rhs.other))
    return false;
  return true;
}

void StructUsingOtherNamespace::readFromJson(const char* jsonText, size_t len)
{
  folly::dynamic parsed = folly::parseJson(folly::StringPiece(jsonText, len));
  if (parsed["other"] != nullptr) {
    this->other.reset(new  ::cpp1::Included());
    this->other->readFromJson(folly::toJson(parsed["other"]).toStdString().c_str());
  }}
void StructUsingOtherNamespace::readFromJson(const char* jsonText)
{
  readFromJson(jsonText, strlen(jsonText));
}

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

  uint32_t xfer = 0;
  std::string fname;
  apache::thrift::protocol::TType ftype;
  int16_t fid;

  ::apache::thrift::reflection::Schema * schema = iprot->getSchema();
  if (schema != nullptr) {
     ::module2_reflection_::reflectionInitializer_8285996275179549516(*schema);
    iprot->setNextStructType(StructUsingOtherNamespace::_reflection_id);
  }
  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) {
          this->other = std::unique_ptr<  ::cpp1::Included>(new  ::cpp1::Included);
          xfer += this->other->read(iprot);
          if (false) {
          } else if (this->other->__isset.some_val) {
          } else { this->other = nullptr; }
        } else {
          xfer += iprot->skip(ftype);
        }
        break;
      default:
        xfer += iprot->skip(ftype);
        break;
    }
    xfer += iprot->readFieldEnd();
  }

  xfer += iprot->readStructEnd();

  return xfer;
}

void StructUsingOtherNamespace::__clear() {
  if (other) other->__clear();
  __isset.__clear();
}
uint32_t StructUsingOtherNamespace::write(apache::thrift::protocol::TProtocol* oprot) const {
  uint32_t xfer = 0;
  xfer += oprot->writeStructBegin("StructUsingOtherNamespace");
  xfer += oprot->writeFieldBegin("other", apache::thrift::protocol::T_STRUCT, 1);
  if (this->other) {xfer += this->other->write(oprot); 
} else {oprot->writeStructBegin("Included"); oprot->writeStructEnd(); oprot->writeFieldStop();}
  xfer += oprot->writeFieldEnd();
  xfer += oprot->writeFieldStop();
  xfer += oprot->writeStructEnd();
  return xfer;
}

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

void merge(const StructUsingOtherNamespace& from, StructUsingOtherNamespace& to) {
  using apache::thrift::merge;
  merge(from.other, to.other);
}

void merge(StructUsingOtherNamespace&& from, StructUsingOtherNamespace& to) {
  using apache::thrift::merge;
  merge(std::move(from.other), to.other);
}


