VoIPServerConfig.h 922 B

12345678910111213141516171819202122232425262728293031323334353637
  1. //
  2. // libtgvoip is free and unencumbered public domain software.
  3. // For more information, see http://unlicense.org or the UNLICENSE file
  4. // you should have received with this source code distribution.
  5. //
  6. #ifndef TGVOIP_VOIPSERVERCONFIG_H
  7. #define TGVOIP_VOIPSERVERCONFIG_H
  8. #include <map>
  9. #include <string>
  10. #include <stdint.h>
  11. #include "threading.h"
  12. #include "json11.hpp"
  13. namespace tgvoip{
  14. class ServerConfig{
  15. public:
  16. ServerConfig();
  17. ~ServerConfig();
  18. static ServerConfig* GetSharedInstance();
  19. int32_t GetInt(std::string name, int32_t fallback);
  20. double GetDouble(std::string name, double fallback);
  21. std::string GetString(std::string name, std::string fallback);
  22. bool GetBoolean(std::string name, bool fallback);
  23. void Update(std::string jsonString);
  24. private:
  25. static ServerConfig* sharedInstance;
  26. bool ContainsKey(std::string key);
  27. json11::Json config;
  28. Mutex mutex;
  29. };
  30. }
  31. #endif //TGVOIP_VOIPSERVERCONFIG_H