- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
C编写Config类读取配置文件
C++编写Config类读取配置文件
博客分类:
C++学习笔记 All
CC++C#OSF#
老外写的一段代码,在Server中编写这个类读取配置文件比较实用
C++代码
//Config.h
#pragma once
#include string
#include map
#include iostream
#include fstream
#include sstream
/*
* \brief Generic configuration Class
*
*/
class Config {
// Data
protected:
std::string m_Delimiter; //! separator between key and value
std::string m_Comment; //! separator between value and comments
std::mapstd::string,std::string m_Contents; //! extracted keys and values
typedef std::mapstd::string,std::string::iterator mapi;
typedef std::mapstd::string,std::string::const_iterator mapci;
// Methods
public:
Config( std::string filename,std::string delimiter = =,std::string comment = # );
Config();
templateclass T T Read( const std::string in_key ) const; //!Search for key and read value or optional default value, call as readT
templateclass T T Read( const std::string in_key, const T in_value ) const;
templateclass T bool ReadInto( T out_var, const std::string in_key ) const;
templateclass T
bool ReadInto( T out_var, const std::string in_key, const T in_value ) const;
bool FileExist(std::string filename);
void ReadFile(std::string filename,std::string delimiter = =,std::string comment = # );
// Check whether key exists in configuration
bool KeyExists( const std::string in_key ) const;
// Modify keys and values
templateclass T void Add( const std::string in_key, const T in_value );
void Remove( const std::string in_key );
// Check or change configuration syntax
std::string GetDelimiter() const { return m_Delimiter; }
std::string GetComment() const { return m_Comment; }
std::string SetDelimiter( const std::string in_s )
{ std::string old = m_Delimiter; m_Delimiter = in_s; return old; }
std::string SetComment( const std
您可能关注的文档
- 2012建造师合同专题讲座(王英).doc
- 康轩教材小班上学期健康教学计划.doc
- 第五章薪酬管理答案2.doc
- 当代中国政治制度复习指导答案.doc
- 华罗庚中学高三生物一轮复习进度安排表.doc
- 西科大自考本科考试工程项目管理2015复习资料.doc
- 保险代理人资格考试模拟题(二).doc
- 2009年11月人力资源国家考试(二级)答案.doc
- 国际运输与保险-保险.doc
- 第六章 工程建设全过程造价管理 [题目答案分离版].docx
- 2026辽宁省面向西北工业大学选调(常规选调)应届优秀大学毕业生笔试模拟试题及答案解析.docx
- 2025年济宁梁山县第二批退役士兵专项公益性岗位选岗考试备考试题及答案解析.docx
- 2025浦发银行昆明分行招聘笔试参考题库附答案解析.docx
- 2025厦门银行南平分行招聘考试参考试题及答案解析.docx
- 2025湖北武汉21世纪经济报道招聘实习记者2人考试备考试题及答案解析.docx
- 2025四川创锦发展控股集团有限公司招聘简历筛选情况考试参考题库及答案解析.docx
- 2026江苏省卫生健康委员会所属事业单位招聘807人考试参考题库及答案解析.docx
- 2026中国农业科学院第一批统一招聘(农田灌溉研究所11人)考试参考题库及答案解析.docx
- 2025年济宁梁山县第二批退役士兵专项公益性岗位选岗考试参考试题及答案解析.docx
- 北京市公安局辅警招聘245人考试参考试题及答案解析.docx
最近下载
- 2025年金融风险管理师主权风险与跨境信贷风险缓释工具专题试卷及解析.pdf VIP
- 2025年四川省国家工作人员法治素养测评(卷二).docx
- 中信建投-迈瑞医疗-300760-长周期拐点来临流水化、数智化、国际化驱动价值重估.pdf VIP
- 全国园林绿化养护概算定额(2018版).docx
- 金匮要略原文.doc VIP
- 《感染性休克Shock》课件.ppt VIP
- 一种机车上砂装置.pdf VIP
- 北京市房山区2022-2023学年五年级上学期语文期末试卷.docx VIP
- 2026年南阳科技职业学院单招职业适应性测试模拟测试卷带答案解析.docx VIP
- JTG∕T F30-2014 公路水泥混凝土路面施工技术细则.docx VIP
原创力文档


文档评论(0)