Config.lua 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. class "Config"
  2. function Config:Config(...)
  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.Config(unpack(arg))
  13. end
  14. end
  15. function Config:loadConfig(configNamespace, fileName)
  16. local retVal = Polycode.Config_loadConfig(self.__ptr, configNamespace, fileName)
  17. end
  18. function Config:saveConfig(configNamespace, fileName)
  19. local retVal = Polycode.Config_saveConfig(self.__ptr, configNamespace, fileName)
  20. end
  21. function Config:getEntry(configNamespace, key)
  22. local retVal = Polycode.Config_getEntry(self.__ptr, configNamespace, key)
  23. if retVal == nil then return nil end
  24. local __c = _G["ConfigEntry"]("__skip_ptr__")
  25. __c.__ptr = retVal
  26. return __c
  27. end
  28. function Config:setStringValue(configNamespace, key, value)
  29. local retVal = Polycode.Config_setStringValue(self.__ptr, configNamespace, key, value)
  30. end
  31. function Config:setNumericValue(configNamespace, key, value)
  32. local retVal = Polycode.Config_setNumericValue(self.__ptr, configNamespace, key, value)
  33. end
  34. function Config:getNumericValue(configNamespace, key)
  35. local retVal = Polycode.Config_getNumericValue(self.__ptr, configNamespace, key)
  36. return retVal
  37. end
  38. function Config:getStringValue(configNamespace, key)
  39. local retVal = Polycode.Config_getStringValue(self.__ptr, configNamespace, key)
  40. return retVal
  41. end
  42. function Config:setBoolValue(configNamespace, key, value)
  43. local retVal = Polycode.Config_setBoolValue(self.__ptr, configNamespace, key, value)
  44. end
  45. function Config:getBoolValue(configNamespace, key)
  46. local retVal = Polycode.Config_getBoolValue(self.__ptr, configNamespace, key)
  47. return retVal
  48. end
  49. function Config:__delete()
  50. if self then Polycode.delete_Config(self.__ptr) end
  51. end