CConfigFile -- ini格式配置文件读取C++封装

hu_zy 2007-01-10 11:48:16

我写的一个用于读取INI格式文件的C++类,下载地址:
http://bbs.showq.net/bbs/viewthread.php?tid=1926&page=1&extra=page%3D1#pid2871

配置文件格式:
name: value
或者
name= value

使用方法:
CConfigFile config("../etc/myconfig.ini");
string myvalue = config["myconfig_name"];


class CConfigFile
{
public:
CConfigFile();
CConfigFile(const char* szFileName);
virtual ~CConfigFile();

public:
string& operator[](const char* szName);
string& operator()(const char* szSection, const char* szName);
int ParseFile(const char* szConfigFile);
int Dump(const char* szConfigFile);
private:
static int StrimString(char* szLine);
int ParseFile();
private:
ifstream m_ConfigFile;
map<string, string> m_ConfigMap;
static string null_string;
};

欢迎大家使用,BUG请及时向我报告,QQ:3994086 email: 3994086@qq.com
...全文
553 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

15,446

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧