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