25 lines
640 B
C++
25 lines
640 B
C++
|
|
#include "mix_cc/utility/read_config.h"
|
|
#include "mix_cc/debug.h"
|
|
#include "mix_cc/json.h"
|
|
#include "mix_cc/utility/config.h"
|
|
#include <filesystem>
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <sstream>
|
|
|
|
namespace mix_cc {
|
|
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) {
|
|
DEBUG_PRINT_MIX_CC(e.what());
|
|
return {};
|
|
} catch (...) {
|
|
DEBUG_PRINT_MIX_CC("read json config file failure with unknown error");
|
|
return {};
|
|
}
|
|
}
|
|
} // namespace mix_cc
|