Loads the configuration from a file.
| 16 | |
| 17 | // Loads the configuration from a file. |
| 18 | void ConfigFile::load(const std::string& file_path) { |
| 19 | std::ifstream file(file_path); |
| 20 | if (!file.is_open()) { MLLM_ERROR_EXIT(ExitCode::kIOError, "Failed to open config file: {}", file_path); } |
| 21 | |
| 22 | try { |
| 23 | // The nlohmann::json stream operator overload handles parsing directly. |
| 24 | file >> json_; |
| 25 | } catch (const nlohmann::json::parse_error& e) { |
| 26 | throw std::runtime_error("JSON parse error in file " + file_path + ": " + e.what()); |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // Loads the configuration from a string. |
| 31 | void ConfigFile::loadString(const std::string& json_str) { |