#ifndef OPENMANUS_CONFIG_H #define OPENMANUS_CONFIG_H #include #include #include #include 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> config_data_; }; } // namespace openmanus #endif // OPENMANUS_CONFIG_H