Добавил скрипты сборки, SQL-файлы и конфигурации
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <configuration/configuration.h>
|
||||
|
||||
json ParseConfiguration(const std::string& path_to_configuration, const json& required_keys) {
|
||||
std::ifstream input(path_to_configuration);
|
||||
auto configuration = json::parse(input);
|
||||
|
||||
for (const auto& [key, value] : required_keys.items()) {
|
||||
// Проверяем наличие ключа на "нулевом" уровне
|
||||
if (!configuration.contains(key)) {
|
||||
std::ostringstream message;
|
||||
message << "configuration doesn't contain required key '" << key << "'";
|
||||
throw std::runtime_error(message.str());
|
||||
}
|
||||
|
||||
// Проверяем наличие вложенных ключей
|
||||
auto configuration_value = configuration[key];
|
||||
|
||||
for (const auto& item : value) {
|
||||
if (!configuration_value.contains(item)) {
|
||||
std::ostringstream message;
|
||||
message << "configuration doesn't contain required key '" << item << "' in '" << key << "'";
|
||||
throw std::runtime_error(message.str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return configuration;
|
||||
}
|
||||
Reference in New Issue
Block a user