WebFramework v3.0.12
Web framework for C++.
Loading...
Searching...
No Matches
Config.h
1#pragma once
2
3#include "Import/WebFrameworkCore.h"
4
5#include "JSONParser.h"
6
7namespace framework
8{
9 namespace utility
10 {
14 class WEB_FRAMEWORK_API Config
15 {
16 private:
17 json::JSONParser currentConfiguration;
18 std::filesystem::path basePath;
19
20 private:
21 template<std::ranges::range T>
22 Config& overrideConfigurationArray(std::string_view key, const T& value, bool recursive);
23
24 private:
25 Config() = default;
26
27 public:
32 Config(const std::filesystem::path& configPath);
33
40 Config(std::string_view serverConfiguration, std::string_view applicationDirectory);
41
42 Config(const Config&) = default;
43
44 Config(Config&&) noexcept = default;
45
46 Config& operator = (const Config&) = default;
47
48 Config& operator = (Config&&) noexcept = default;
49
57 Config& overrideConfiguration(std::string_view key, const json::utility::jsonObject::variantType& value, bool recursive = true);
58
66 Config& overrideConfiguration(std::string_view key, const std::vector<int64_t>& value, bool recursive = true);
67
75 Config& overrideConfiguration(std::string_view key, const std::vector<std::string>& value, bool recursive = true);
76
82 Config& overrideBasePath(const std::filesystem::path& basePath);
83
90 const std::string& getConfigurationString(std::string_view key, bool recursive = true) const;
91
98 int64_t getConfigurationInteger(std::string_view key, bool recursive = true) const;
99
106 bool getConfigurationBoolean(std::string_view key, bool recursive = true) const;
107
112 const std::filesystem::path& getBasePath() const;
113
118 std::string getConfiguration() const;
119
124 std::string_view getRawConfiguration() const;
125
130 const json::JSONParser& operator * () const;
131
132 ~Config() = default;
133 };
134 }
135}
Config file representation.
Definition Config.h:15
Config(std::string_view serverConfiguration, std::string_view applicationDirectory)
Create config from text.
Config(const std::filesystem::path &configPath)