2
0

Config.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. class "Config"
  2. function Config:Config(...)
  3. for k,v in pairs(arg) do
  4. if type(v) == "table" then
  5. if v.__ptr ~= nil then
  6. arg[k] = v.__ptr
  7. end
  8. end
  9. end
  10. if self.__ptr == nil and arg[1] ~= "__skip_ptr__" then
  11. self.__ptr = Polycore.Config(unpack(arg))
  12. end
  13. end
  14. function Config:loadConfig(configNamespace, fileName)
  15. local retVal = Polycore.Config_loadConfig(self.__ptr, configNamespace, fileName)
  16. end
  17. function Config:saveConfig(configNamespace, fileName)
  18. local retVal = Polycore.Config_saveConfig(self.__ptr, configNamespace, fileName)
  19. end
  20. function Config:getEntry(configNamespace, key)
  21. local retVal = Polycore.Config_getEntry(self.__ptr, configNamespace, key)
  22. if Polycore.__ptr_lookup[retVal] ~= nil then
  23. return Polycore.__ptr_lookup[retVal]
  24. else
  25. Polycore.__ptr_lookup[retVal] = ConfigEntry("__skip_ptr__")
  26. Polycore.__ptr_lookup[retVal].__ptr = retVal
  27. return Polycore.__ptr_lookup[retVal]
  28. end
  29. end
  30. function Config:setStringValue(configNamespace, key, value)
  31. local retVal = Polycore.Config_setStringValue(self.__ptr, configNamespace, key, value)
  32. end
  33. function Config:setNumericValue(configNamespace, key, value)
  34. local retVal = Polycore.Config_setNumericValue(self.__ptr, configNamespace, key, value)
  35. end
  36. function Config:getNumericValue(configNamespace, key)
  37. local retVal = Polycore.Config_getNumericValue(self.__ptr, configNamespace, key)
  38. return retVal
  39. end
  40. function Config:getStringValue(configNamespace, key)
  41. local retVal = Polycore.Config_getStringValue(self.__ptr, configNamespace, key)
  42. return retVal
  43. end