FreeRDP
sdl_prefs.hpp
1 
20 #pragma once
21 
22 #include <string>
23 #include <vector>
24 #include <memory>
25 #include <winpr/json.h>
26 
27 class SdlPref
28 {
29  public:
30  static std::shared_ptr<SdlPref> instance(const std::string& name = SdlPref::get_default_file());
31 
32  std::string get_pref_file();
33 
34  std::string get_string(const std::string& key, const std::string& fallback = "");
35  int64_t get_int(const std::string& key, int64_t fallback = 0);
36  bool get_bool(const std::string& key, bool fallback = false);
37  std::vector<std::string> get_array(const std::string& key,
38  const std::vector<std::string>& fallback = {});
39 
40  static void print_config_file_help(int version);
41 
42  private:
43  using WINPR_JSONPtr = std::unique_ptr<WINPR_JSON, decltype(&WINPR_JSON_Delete)>;
44 
45  std::string _name;
46  WINPR_JSONPtr _config;
47 
48  explicit SdlPref(std::string file);
49 
50  WINPR_JSON* get_item(const std::string& key);
51  WINPR_JSONPtr get();
52 
53  static std::string get_pref_dir();
54  static std::string get_default_file();
55  static std::string item_to_str(WINPR_JSON* item, const std::string& fallback = "");
56 };
WINPR_API void WINPR_JSON_Delete(WINPR_JSON *item)
Delete a WinPR JSON wrapper object.
Definition: json.c:144