# File rbBinaryCFPropertyList.rb, line 65
    def to_str(opts={})
      @unique_table = {}
      @count_objects = 0
      @string_size = 0
      @int_size = 0
      @misc_size = 0
      @object_refs = 0

      @written_object_count = 0
      @object_table = []
      @object_ref_size = 0

      @offsets = []

      binary_str = "bplist00"
      unique_and_count_values(opts[:root])

      @count_objects += @unique_table.count
      @object_ref_size = Binary.bytes_needed(@count_objects)

      file_size = @string_size + @int_size + @misc_size + @object_refs * @object_ref_size + 40
      offset_size = Binary.bytes_needed(file_size)
      table_offset = file_size - 32

      @object_table = []
      @written_object_count = 0
      @unique_table = {} # we needed it to calculate several values, but now we need an empty table

      opts[:root].to_binary(self)

      object_offset = 8
      offsets = []

      0.upto(@object_table.count-1) do |i|
        binary_str += @object_table[i]
        offsets[i] = object_offset
        object_offset += @object_table[i].bytesize
      end

      offsets.each do |offset|
        binary_str += Binary.pack_it_with_size(offset_size,offset)
      end

      binary_str += [offset_size, @object_ref_size].pack("x6CC")
      binary_str += [@count_objects].pack("x4N")
      binary_str += [0].pack("x4N")
      binary_str += [table_offset].pack("x4N")

      return binary_str
    end