-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathverified_config_attributes.h
More file actions
55 lines (40 loc) · 1.82 KB
/
Copy pathverified_config_attributes.h
File metadata and controls
55 lines (40 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#pragma once
#include <filesystem>
#include <optional>
#include <unordered_map>
#include "config/config_key_path.h"
#include "config/config_value.h"
namespace silo::config {
/// A VerifiedConfigAttributes is providing I/O-, key error and parse
/// error free access to a set of configuration data.
///
/// The accessors return an option since even though invalid options are
/// not present in this, the given option may also not be present.
///
/// `positional_arguments` and `asks_for_help` are only used by the command
/// line argument backend, other backends leave them empty/false.
class VerifiedConfigAttributes {
public:
std::unordered_map<ConfigKeyPath, ConfigValue> config_values;
[[nodiscard]] std::optional<std::string> getString(const ConfigKeyPath& config_key_path) const;
[[nodiscard]] std::optional<std::filesystem::path> getPath(const ConfigKeyPath& config_key_path
) const;
[[nodiscard]] std::optional<int32_t> getInt32(const ConfigKeyPath& config_key_path) const;
[[nodiscard]] std::optional<uint32_t> getUint32(const ConfigKeyPath& config_key_path) const;
[[nodiscard]] std::optional<uint16_t> getUint16(const ConfigKeyPath& config_key_path) const;
[[nodiscard]] std::optional<bool> getBool(const ConfigKeyPath& config_key_path) const;
[[nodiscard]] std::optional<std::vector<std::string>> getList(
const ConfigKeyPath& config_key_path
) const;
};
class VerifiedCommandLineArguments : public VerifiedConfigAttributes {
public:
std::vector<std::string> positional_arguments;
bool asks_for_help;
static VerifiedCommandLineArguments askingForHelp();
static VerifiedCommandLineArguments fromConfigValuesAndPositionalArguments(
std::unordered_map<ConfigKeyPath, ConfigValue> config_values,
std::vector<std::string> positional_arguments
);
};
} // namespace silo::config