8#include <unordered_map>
13 using ConfigValue = std::variant<std::string, int, float, bool, std::vector<uint8_t>>;
21 auto it =
values.find(key);
24 if (
const auto* p = std::get_if<T>(&it->second)) {
30 bool isKey(
const std::string& key)
const;
33 std::unordered_map<std::string, ConfigValue>
values;
36 static std::tuple<std::string, std::string, std::string>
parseLine(
const std::string& line);
#define RET_IF_ERR_MSG(condition, errorCode, message)
Macro to return an error with an error message if a condition is met.
Represents an error with both an error code and a message.
Encapsulates a result that can hold either a value or an Error.
Parses and stores config values from custom file format.
std::variant< std::string, int, float, bool, std::vector< uint8_t > > ConfigValue
bool isKey(const std::string &key) const
static CCSDS::ResultBuffer parseBytes(const std::string &valueStr)
Parse string "[1,2,3]" into vector<uint8_t>
std::unordered_map< std::string, ConfigValue > values
CCSDS::ResultBool load(const std::string &filename)
Load config file.
CCSDS::Result< T > get(const std::string &key) const
Get value by key and type.
static std::tuple< std::string, std::string, std::string > parseLine(const std::string &line)
Parse a single line from config.
@ NO_DATA
No data available.
@ INVALID_DATA
Data is invalid.