mmCEsim 0.3.0
mmWave Channel Estimation Simulation
config.h
Go to the documentation of this file.
1
12#ifndef _CONFIG_H_
13#define _CONFIG_H_
14
15#include "log_global.h"
16#include "term.h"
17#include "utils.h"
18#include "yaml.h"
19#include <array>
20#include <exception>
21#include <filesystem>
22#include <fmt/core.h>
23#include <fstream>
24#include <string>
25
26static std::array valid_configs = { "latex"s, "cpp"s, "cppflags"s };
27
33class Config {
34 public:
40 Config();
41
49 std::string operator[](const std::string& key) const;
50
61 bool set(const std::string& key, const std::string& v);
62
63 size_t size() const noexcept;
64
65 bool write() const;
66
67 static std::string read(const std::string& key, std::string* msg = nullptr);
68
69 static std::string read(const std::string& key, const std::string& default_val, std::string* msg = nullptr);
70
71 static bool edit(const std::string& key, const std::string& v, std::string* msg = nullptr);
72
73 private:
74 bool _load();
75
76 YAML::Node _config;
77};
78
79inline size_t Config::size() const noexcept { return _config.size(); }
80
81#endif
User configuration.
Definition: config.h:33
bool _load()
Definition: config.cpp:127
std::string operator[](const std::string &key) const
Read the key.
Definition: config.cpp:16
bool write() const
Definition: config.cpp:62
bool set(const std::string &key, const std::string &v)
Set the key value.
Definition: config.cpp:38
YAML::Node _config
Definition: config.h:76
size_t size() const noexcept
Definition: config.h:79
static bool edit(const std::string &key, const std::string &v, std::string *msg=nullptr)
Definition: config.cpp:106
Config()
Construct a new Config object.
Definition: config.cpp:14
static std::string read(const std::string &key, std::string *msg=nullptr)
Definition: config.cpp:76
static std::array valid_configs
Definition: config.h:26
Global Access of Log.
Terminal Color and Style Control.
Utilities.
Wrapper for yaml-cpp for static linking.