]> git.stg.codes - stg.git/blob - include/stg/module_settings.h
Use std::lock_guard instead of STG_LOCKER.
[stg.git] / include / stg / module_settings.h
1 #pragma once
2
3 #include <string>
4 #include <vector>
5 #include <cstring> // strcasecmp
6
7 namespace STG
8 {
9
10 //-----------------------------------------------------------------------------
11 struct ParamValue
12 {
13     ParamValue() = default;
14     ParamValue(const std::string& p, const std::vector<std::string>& vs) noexcept
15         : param(p),
16           value(vs)
17     {}
18     ParamValue(const std::string& p, const std::vector<std::string>& vs, const std::vector<ParamValue>& ss) noexcept
19         : param(p),
20           value(vs),
21           sections(ss)
22     {}
23
24     ParamValue(const ParamValue&) = default;
25     ParamValue& operator=(const ParamValue&) = default;
26     ParamValue(ParamValue&&) = default;
27     ParamValue& operator=(ParamValue&&) = default;
28
29     bool operator==(const ParamValue & rhs) const noexcept
30     { return !strcasecmp(param.c_str(), rhs.param.c_str()); }
31
32     bool operator<(const ParamValue & rhs) const noexcept
33     { return strcasecmp(param.c_str(), rhs.param.c_str()) < 0; }
34
35     std::string param;
36     std::vector<std::string> value;
37     std::vector<ParamValue> sections;
38 };
39 //-----------------------------------------------------------------------------
40 struct ModuleSettings
41 {
42     ModuleSettings() = default;
43     ModuleSettings(const std::string& name, const std::vector<ParamValue>& params) noexcept
44         : moduleName(name),
45           moduleParams(params)
46     {}
47
48     ModuleSettings(const ModuleSettings&) = default;
49     ModuleSettings& operator=(const ModuleSettings&) = default;
50     ModuleSettings(ModuleSettings&&) = default;
51     ModuleSettings& operator=(ModuleSettings&&) = default;
52
53     bool operator==(const ModuleSettings & rhs) const noexcept
54     { return !strcasecmp(moduleName.c_str(), rhs.moduleName.c_str()); }
55
56     bool operator<(const ModuleSettings & rhs) const noexcept
57     { return strcasecmp(moduleName.c_str(), rhs.moduleName.c_str()) < 0; }
58
59     std::string             moduleName;
60     std::vector<ParamValue> moduleParams;
61 };
62 //-----------------------------------------------------------------------------
63
64 }