21 lines
540 B
C++
21 lines
540 B
C++
|
|
#include <TestProject/DCR/connection/read_config.h>
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <nlohmann/json.hpp>
|
|
#include <sstream>
|
|
#define CONFIG_FILE_PATH "/users/dsc/code/config/config.json"
|
|
namespace DCR {
|
|
maybe<json> read_config_maybe(std::string&& category, std::string&& entry) {
|
|
try {
|
|
auto data = fp::read_text_file(CONFIG_FILE_PATH)();
|
|
return json::parse(data).at(category).at(entry);
|
|
} catch (std::exception& e) {
|
|
return {};
|
|
} catch (...) {
|
|
return {};
|
|
}
|
|
}
|
|
} // namespace DCR
|