forked from AMSC-24-25/amsc-24-25-classroom-20-fft-FFT
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjson-configuration-loader.hpp
32 lines (26 loc) · 1.17 KB
/
json-configuration-loader.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#ifndef JSON_CONFIGURATION_LOADER_HPP
#define JSON_CONFIGURATION_LOADER_HPP
#include <nlohmann/json.hpp>
#include "json-field-handler.hpp"
#include "config-loader/abstract-configuration-loader.hpp"
/**
* JSONConfigurationLoader is a concrete class that implements the AbstractConfigurationLoader interface.
*/
class JSONConfigurationLoader final : public AbstractConfigurationLoader {
std::optional<JsonFieldHandler> configurationData;
public:
/**
* Get the configuration data that was loaded.
* @return The configuration data as a JsonFieldHandler object.
* @throw std::runtime_error If no configuration data was loaded.
*/
[[nodiscard]] const JsonFieldHandler &getConfigurationData() const;
/**
* Given a file path to a JSON file, load the configuration from the file.
* @param filePath The path to the configuration file.
* @throw std::runtime_error If the file is not a JSON file; the file cannot be opened;
the file is empty; the file is not in JSON format (after loading).
*/
void loadConfigurationFromFile(const std::string &filePath) override;
};
#endif //JSON_CONFIGURATION_LOADER_HPP