Config.lua 1.9 KB

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