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 [[nodiscard]] static std::shared_ptr<SdlPref>
31 instance(const std::string& name = SdlPref::get_default_file(false),
32 const std::string& systemName = SdlPref::get_default_file(true));
33
34 [[nodiscard]] std::string get_pref_file(bool systemConfigOnly = false) const;
35
36 [[nodiscard]] std::string get_string(const std::string& key, const std::string& fallback = "",
37 bool systemConfigOnly = false) const;
38 [[nodiscard]] int64_t get_int(const std::string& key, int64_t fallback = 0,
39 bool systemConfigOnly = false) const;
40 [[nodiscard]] bool get_bool(const std::string& key, bool fallback = false,
41 bool systemConfigOnly = false) const;
42 [[nodiscard]] std::vector<std::string> get_array(const std::string& key,
43 const std::vector<std::string>& fallback = {},
44 bool systemConfigOnly = false) const;
45
46 [[nodiscard]] bool is_commandline_override_allowed() const;
47
48 static void print_config_file_help(int version);
49
50 private:
51 using WINPR_JSONPtr = std::unique_ptr<WINPR_JSON, decltype(&WINPR_JSON_Delete)>;
52
53 std::string _name;
54 std::string _system_name;
55 WINPR_JSONPtr _config;
56 WINPR_JSONPtr _system_config;
57
58 SdlPref(std::string file, std::string systemFile);
59
60 [[nodiscard]] WINPR_JSON* get_item(const std::string& key, bool systemConfigOnly) const;
61 [[nodiscard]] WINPR_JSON* get_item(const WINPR_JSONPtr& config, const std::string& key) const;
62
63 [[nodiscard]] WINPR_JSONPtr get(bool systemConfigOnly) const;
64 [[nodiscard]] bool get_bool(const WINPR_JSONPtr& config, const std::string& key,
65 bool fallback = false) const;
66
67 [[nodiscard]] bool is_user_config_enabled() const;
68
69 [[nodiscard]] static std::string get_default_file(bool systemConfigOnly);
70 [[nodiscard]] static std::string item_to_str(WINPR_JSON* item,
71 const std::string& fallback = "");
72};
WINPR_API void WINPR_JSON_Delete(WINPR_JSON *item)
Delete a WinPR JSON wrapper object.
Definition c-json.c:103