mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-01 17:03:19 +00:00
35 lines
875 B
C++
35 lines
875 B
C++
/*
|
|
* Mirai. Copyright (C) 2024 Vyn
|
|
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
|
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
|
*/
|
|
|
|
#include "Config.h"
|
|
#include "nlohmann/json.hpp"
|
|
#include <fstream>
|
|
#include <iostream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace mirai
|
|
{
|
|
Config::Config(const std::string &path) : path_(path)
|
|
{
|
|
std::ifstream file(path_);
|
|
configJson_ = nlohmann::json::parse(file);
|
|
}
|
|
|
|
std::vector<std::string> Config::sources() const
|
|
{
|
|
std::vector<std::string> sources;
|
|
assert(configJson_.is_object());
|
|
assert(configJson_["files"].is_array());
|
|
auto jsonSources = configJson_["files"];
|
|
for (const auto &filePath : jsonSources) {
|
|
assert(filePath.is_string());
|
|
sources.push_back(filePath.get<std::string>());
|
|
}
|
|
return sources;
|
|
}
|
|
|
|
}; // namespace mirai
|