BinaryObjectWriter.lua 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. class "BinaryObjectWriter"
  2. function BinaryObjectWriter:BinaryObjectWriter(...)
  3. local arg = {...}
  4. for k,v in pairs(arg) do
  5. if type(v) == "table" then
  6. if v.__ptr ~= nil then
  7. arg[k] = v.__ptr
  8. end
  9. end
  10. end
  11. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  12. self.__ptr = Polycode.BinaryObjectWriter(unpack(arg))
  13. end
  14. end
  15. function BinaryObjectWriter:parseKeysFromObjectEntry(entry)
  16. local retVal = Polycode.BinaryObjectWriter_parseKeysFromObjectEntry(self.__ptr, entry.__ptr)
  17. end
  18. function BinaryObjectWriter:writeEntryToFile(entry)
  19. local retVal = Polycode.BinaryObjectWriter_writeEntryToFile(self.__ptr, entry.__ptr)
  20. end
  21. function BinaryObjectWriter:addKey(key)
  22. local retVal = Polycode.BinaryObjectWriter_addKey(self.__ptr, key)
  23. return retVal
  24. end
  25. function BinaryObjectWriter:getKeyIndex(key)
  26. local retVal = Polycode.BinaryObjectWriter_getKeyIndex(self.__ptr, key)
  27. return retVal
  28. end
  29. function BinaryObjectWriter:writeToFile(fileName)
  30. local retVal = Polycode.BinaryObjectWriter_writeToFile(self.__ptr, fileName)
  31. return retVal
  32. end
  33. function BinaryObjectWriter:__delete()
  34. if self then Polycode.delete_BinaryObjectWriter(self.__ptr) end
  35. end