openmanus.cpp/include/config.h

72 lines
1.8 KiB
C
Raw Normal View History

2025-03-10 02:38:39 +08:00
#ifndef OPENMANUS_CONFIG_H
#define OPENMANUS_CONFIG_H
#include <string>
#include <map>
#include <fstream>
#include <sstream>
namespace openmanus {
/**
* @class Config
* @brief TOML
*/
class Config {
public:
/**
* @brief
* @param config_file
*/
Config(const std::string& config_file = "config.toml");
/**
* @brief
* @param config_file
* @return
*/
bool load(const std::string& config_file);
/**
* @brief
* @param section
* @param key
* @param default_value
* @return
*/
std::string getString(const std::string& section, const std::string& key, const std::string& default_value = "") const;
/**
* @brief
* @param section
* @param key
* @param default_value
* @return
*/
int getInt(const std::string& section, const std::string& key, int default_value = 0) const;
/**
* @brief
* @param section
* @param key
* @param default_value
* @return
*/
double getDouble(const std::string& section, const std::string& key, double default_value = 0.0) const;
/**
* @brief
* @param section
* @param key
* @param default_value
* @return
*/
bool getBool(const std::string& section, const std::string& key, bool default_value = false) const;
private:
std::map<std::string, std::map<std::string, std::string>> config_data_;
};
} // namespace openmanus
#endif // OPENMANUS_CONFIG_H