30 lines
709 B
C++
30 lines
709 B
C++
#ifndef CONFIGPARSER_H
|
|
#define CONFIGPARSER_H
|
|
/**
|
|
* 配置文件解析模块
|
|
* 目标:实现对多种文件格式的解析功能
|
|
* 1、ini格式文件 √
|
|
* 2、json格式文件 未实现
|
|
* 3、YAML格式文件 未实现
|
|
* 4、Protobuf格式文件 未实现
|
|
*/
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
/** 状态码 */
|
|
enum CPStatus {
|
|
CPSUCCESS = 0,//成功
|
|
CPFILE = -1//文件错误
|
|
};
|
|
|
|
/**
|
|
* 读取ini类型的配置文件
|
|
* @param path 配置文件路径
|
|
* @param config 存储配置文件的unordered_map容器
|
|
* @return 状态码
|
|
*/
|
|
CPStatus configFromIni(const std::string &path, std::unordered_map<std::string, std::string> &config);
|
|
|
|
|
|
#endif //CONFIGPARSER_H
|