#
# Autogenerated by Thrift
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#

require 'thrift/protocol/tprotocol'

module Numberz
  ONE = 1
  TWO = 2
  THREE = 3
  FIVE = 5
  SIX = 6
  EIGHT = 8
end

class Bonk

  attr_writer :message, :type
  attr_reader :message, :type

  def initialize(d=nil)
    if (d != nil)
      if (d.has_key?('message'))
        @message = d['message']
      end
      if (d.has_key?('type'))
        @type = d['type']
      end
    end
  end

  def read(iprot)
    iprot.readStructBegin()
    while true
      fname, ftype, fid = iprot.readFieldBegin()
      if (ftype === TType::STOP)
        break
      end
      if (fid == 1)
        if (ftype === TType::STRING)
          @message = iprot.readString();
        else
          iprot.skip(ftype)
        end
      elsif (fid == 2)
        if (ftype === TType::I32)
          @type = iprot.readI32();
        else
          iprot.skip(ftype)
        end
      else
        iprot.skip(ftype)
      end
      iprot.readFieldEnd()
    end
    iprot.readStructEnd()
  end

  def write(oprot)
    oprot.writeStructBegin('Bonk')
    if (@message != nil)
      oprot.writeFieldBegin('message', TType::STRING, 1)
      oprot.writeString(@message)
      oprot.writeFieldEnd()
    end
    if (@type != nil)
      oprot.writeFieldBegin('type', TType::I32, 2)
      oprot.writeI32(@type)
      oprot.writeFieldEnd()
    end
    oprot.writeFieldStop()
    oprot.writeStructEnd()
  end

end

class Xtruct

  attr_writer :string_thing, :byte_thing, :i32_thing, :i64_thing
  attr_reader :string_thing, :byte_thing, :i32_thing, :i64_thing

  def initialize(d=nil)
    if (d != nil)
      if (d.has_key?('string_thing'))
        @string_thing = d['string_thing']
      end
      if (d.has_key?('byte_thing'))
        @byte_thing = d['byte_thing']
      end
      if (d.has_key?('i32_thing'))
        @i32_thing = d['i32_thing']
      end
      if (d.has_key?('i64_thing'))
        @i64_thing = d['i64_thing']
      end
    end
  end

  def read(iprot)
    iprot.readStructBegin()
    while true
      fname, ftype, fid = iprot.readFieldBegin()
      if (ftype === TType::STOP)
        break
      end
      if (fid == 1)
        if (ftype === TType::STRING)
          @string_thing = iprot.readString();
        else
          iprot.skip(ftype)
        end
      elsif (fid == 4)
        if (ftype === TType::BYTE)
          @byte_thing = iprot.readByte();
        else
          iprot.skip(ftype)
        end
      elsif (fid == 9)
        if (ftype === TType::I32)
          @i32_thing = iprot.readI32();
        else
          iprot.skip(ftype)
        end
      elsif (fid == 11)
        if (ftype === TType::I64)
          @i64_thing = iprot.readI64();
        else
          iprot.skip(ftype)
        end
      else
        iprot.skip(ftype)
      end
      iprot.readFieldEnd()
    end
    iprot.readStructEnd()
  end

  def write(oprot)
    oprot.writeStructBegin('Xtruct')
    if (@string_thing != nil)
      oprot.writeFieldBegin('string_thing', TType::STRING, 1)
      oprot.writeString(@string_thing)
      oprot.writeFieldEnd()
    end
    if (@byte_thing != nil)
      oprot.writeFieldBegin('byte_thing', TType::BYTE, 4)
      oprot.writeByte(@byte_thing)
      oprot.writeFieldEnd()
    end
    if (@i32_thing != nil)
      oprot.writeFieldBegin('i32_thing', TType::I32, 9)
      oprot.writeI32(@i32_thing)
      oprot.writeFieldEnd()
    end
    if (@i64_thing != nil)
      oprot.writeFieldBegin('i64_thing', TType::I64, 11)
      oprot.writeI64(@i64_thing)
      oprot.writeFieldEnd()
    end
    oprot.writeFieldStop()
    oprot.writeStructEnd()
  end

end

class Xtruct2

  attr_writer :byte_thing, :struct_thing, :i32_thing
  attr_reader :byte_thing, :struct_thing, :i32_thing

  def initialize(d=nil)
    if (d != nil)
      if (d.has_key?('byte_thing'))
        @byte_thing = d['byte_thing']
      end
      if (d.has_key?('struct_thing'))
        @struct_thing = d['struct_thing']
      end
      if (d.has_key?('i32_thing'))
        @i32_thing = d['i32_thing']
      end
    end
  end

  def read(iprot)
    iprot.readStructBegin()
    while true
      fname, ftype, fid = iprot.readFieldBegin()
      if (ftype === TType::STOP)
        break
      end
      if (fid == 1)
        if (ftype === TType::BYTE)
          @byte_thing = iprot.readByte();
        else
          iprot.skip(ftype)
        end
      elsif (fid == 2)
        if (ftype === TType::STRUCT)
          @struct_thing = Xtruct.new()
          @struct_thing.read(iprot)
        else
          iprot.skip(ftype)
        end
      elsif (fid == 3)
        if (ftype === TType::I32)
          @i32_thing = iprot.readI32();
        else
          iprot.skip(ftype)
        end
      else
        iprot.skip(ftype)
      end
      iprot.readFieldEnd()
    end
    iprot.readStructEnd()
  end

  def write(oprot)
    oprot.writeStructBegin('Xtruct2')
    if (@byte_thing != nil)
      oprot.writeFieldBegin('byte_thing', TType::BYTE, 1)
      oprot.writeByte(@byte_thing)
      oprot.writeFieldEnd()
    end
    if (@struct_thing != nil)
      oprot.writeFieldBegin('struct_thing', TType::STRUCT, 2)
      @struct_thing.write(oprot)
      oprot.writeFieldEnd()
    end
    if (@i32_thing != nil)
      oprot.writeFieldBegin('i32_thing', TType::I32, 3)
      oprot.writeI32(@i32_thing)
      oprot.writeFieldEnd()
    end
    oprot.writeFieldStop()
    oprot.writeStructEnd()
  end

end

class Insanity

  attr_writer :userMap, :xtructs
  attr_reader :userMap, :xtructs

  def initialize(d=nil)
    if (d != nil)
      if (d.has_key?('userMap'))
        @userMap = d['userMap']
      end
      if (d.has_key?('xtructs'))
        @xtructs = d['xtructs']
      end
    end
  end

  def read(iprot)
    iprot.readStructBegin()
    while true
      fname, ftype, fid = iprot.readFieldBegin()
      if (ftype === TType::STOP)
        break
      end
      if (fid == 1)
        if (ftype === TType::MAP)
          @userMap = {}
          (_ktype1, _vtype2, _size0 ) = iprot.readMapBegin() 
          for _i4 in (1.._size0)
            _key5 = iprot.readI32();
            _val6 = iprot.readI64();
            @userMap[_key5] = _val6
          end
          iprot.readMapEnd()
        else
          iprot.skip(ftype)
        end
      elsif (fid == 2)
        if (ftype === TType::LIST)
          @xtructs = []
          (_etype10, _size7) = iprot.readListBegin()
          for _i11 in (1.._size7)
            _elem12 = Xtruct.new()
            _elem12.read(iprot)
            @xtructs.push(_elem12)
          end
          iprot.readListEnd()
        else
          iprot.skip(ftype)
        end
      else
        iprot.skip(ftype)
      end
      iprot.readFieldEnd()
    end
    iprot.readStructEnd()
  end

  def write(oprot)
    oprot.writeStructBegin('Insanity')
    if (@userMap != nil)
      oprot.writeFieldBegin('userMap', TType::MAP, 1)
      oprot.writeMapBegin(TType::I32, TType::I64, @userMap.length)
      @userMap.each do |kiter13, viter14|
        oprot.writeI32(kiter13)
        oprot.writeI64(viter14)
      end
      oprot.writeMapEnd()
      oprot.writeFieldEnd()
    end
    if (@xtructs != nil)
      oprot.writeFieldBegin('xtructs', TType::LIST, 2)
      oprot.writeListBegin(TType::STRUCT, @xtructs.length)
      @xtructs.each do |iter15|
        iter15.write(oprot)
      end
      oprot.writeListEnd()
      oprot.writeFieldEnd()
    end
    oprot.writeFieldStop()
    oprot.writeStructEnd()
  end

end

class EmptyStruct

  def initialize(d=nil)
  end

  def read(iprot)
    iprot.readStructBegin()
    while true
      fname, ftype, fid = iprot.readFieldBegin()
      if (ftype === TType::STOP)
        break
      else
        iprot.skip(ftype)
      end
      iprot.readFieldEnd()
    end
    iprot.readStructEnd()
  end

  def write(oprot)
    oprot.writeStructBegin('EmptyStruct')
    oprot.writeFieldStop()
    oprot.writeStructEnd()
  end

end

class OneField

  attr_writer :field
  attr_reader :field

  def initialize(d=nil)
    if (d != nil)
      if (d.has_key?('field'))
        @field = d['field']
      end
    end
  end

  def read(iprot)
    iprot.readStructBegin()
    while true
      fname, ftype, fid = iprot.readFieldBegin()
      if (ftype === TType::STOP)
        break
      end
      if (fid == 1)
        if (ftype === TType::STRUCT)
          @field = EmptyStruct.new()
          @field.read(iprot)
        else
          iprot.skip(ftype)
        end
      else
        iprot.skip(ftype)
      end
      iprot.readFieldEnd()
    end
    iprot.readStructEnd()
  end

  def write(oprot)
    oprot.writeStructBegin('OneField')
    if (@field != nil)
      oprot.writeFieldBegin('field', TType::STRUCT, 1)
      @field.write(oprot)
      oprot.writeFieldEnd()
    end
    oprot.writeFieldStop()
    oprot.writeStructEnd()
  end

end

class Xception < StandardError

  attr_writer :errorCode, :message
  attr_reader :errorCode, :message

  def initialize(d=nil)
    if (d != nil)
      if (d.has_key?('errorCode'))
        @errorCode = d['errorCode']
      end
      if (d.has_key?('message'))
        @message = d['message']
      end
    end
  end

  def read(iprot)
    iprot.readStructBegin()
    while true
      fname, ftype, fid = iprot.readFieldBegin()
      if (ftype === TType::STOP)
        break
      end
      if (fid == 1)
        if (ftype === TType::I32)
          @errorCode = iprot.readI32();
        else
          iprot.skip(ftype)
        end
      elsif (fid == 2)
        if (ftype === TType::STRING)
          @message = iprot.readString();
        else
          iprot.skip(ftype)
        end
      else
        iprot.skip(ftype)
      end
      iprot.readFieldEnd()
    end
    iprot.readStructEnd()
  end

  def write(oprot)
    oprot.writeStructBegin('Xception')
    if (@errorCode != nil)
      oprot.writeFieldBegin('errorCode', TType::I32, 1)
      oprot.writeI32(@errorCode)
      oprot.writeFieldEnd()
    end
    if (@message != nil)
      oprot.writeFieldBegin('message', TType::STRING, 2)
      oprot.writeString(@message)
      oprot.writeFieldEnd()
    end
    oprot.writeFieldStop()
    oprot.writeStructEnd()
  end

end

class Xception2 < StandardError

  attr_writer :errorCode, :struct_thing
  attr_reader :errorCode, :struct_thing

  def initialize(d=nil)
    if (d != nil)
      if (d.has_key?('errorCode'))
        @errorCode = d['errorCode']
      end
      if (d.has_key?('struct_thing'))
        @struct_thing = d['struct_thing']
      end
    end
  end

  def read(iprot)
    iprot.readStructBegin()
    while true
      fname, ftype, fid = iprot.readFieldBegin()
      if (ftype === TType::STOP)
        break
      end
      if (fid == 1)
        if (ftype === TType::I32)
          @errorCode = iprot.readI32();
        else
          iprot.skip(ftype)
        end
      elsif (fid == 2)
        if (ftype === TType::STRUCT)
          @struct_thing = Xtruct.new()
          @struct_thing.read(iprot)
        else
          iprot.skip(ftype)
        end
      else
        iprot.skip(ftype)
      end
      iprot.readFieldEnd()
    end
    iprot.readStructEnd()
  end

  def write(oprot)
    oprot.writeStructBegin('Xception2')
    if (@errorCode != nil)
      oprot.writeFieldBegin('errorCode', TType::I32, 1)
      oprot.writeI32(@errorCode)
      oprot.writeFieldEnd()
    end
    if (@struct_thing != nil)
      oprot.writeFieldBegin('struct_thing', TType::STRUCT, 2)
      @struct_thing.write(oprot)
      oprot.writeFieldEnd()
    end
    oprot.writeFieldStop()
    oprot.writeStructEnd()
  end

end