如今不同的编程工具基本上都有相应的日志打印程序,如.NET对应的日志打印程序为Log4Net,Java对应的日志打印程序为Log4J,当让C++也有相应的日志打印程序。对于C++开发人员来说,Log4Cplus是一款较好的开源日志程序。

Log4Cplus是一款支持在2个平台上开发的开源日志,这2个开发平台分别是Windows和Linux,本人对Linux不熟,在此就介绍该日志打印程序在Linux下的应用,仅介绍Windows平台上使用该日志打印系统。该日志的sourcecode 路径:[待上传]。

以下是该日志答应文件的源码解析:

  1. Property.CS [Function members]:

[Constructor|Destructor]
Properties():无参构造函数
Properties(istream& input):参数为istream& 类型的构造函数,input的数据信息来源为读取的文件配置文件【urconfig.properties】
Properties(const string& inputFile):参数为const string&类型的构造函数,inputFile为配置文件【urconfig.properties】的路径
~Properties():析构函数

[Public]
void init(istream& input):解析配置文件【urconfig.properties】中的信息,将该配置文件中的信息解析成Key-Value形式
bool exists(const string& key) const:配置属性是否存在名字为key的键值对
bool exists(char const* key) const:同上,重载
string const& getProperty(const string& key) const:根据Key值获取Value值
string const& getProperty(char const* key) const:同上,重载
string getProperty(const string& key, const string& defaultVal) const:根据Key值获取Value值,如果Key不存在则返回defaultVal
vector<string> propertyNames() const:返回所有属性的Key值
void setProperty(const string& key, const string& stringvalue):根据属性的Key值设置属性Value
bool removeProperty(const string& key):删除主键为Key的属性
Properties getPropertySubset(const string& prefix) const:获取Key值以prefix开头的所有属性
bool getInt(int& val, string const& key) const:根据Key值获取属性的Value,并将Value值转换成int类型返回
bool getUInt(unsigned & val, string const& key) const:根据Key值获取属性的Value,并将Value值转换成unsigned int & 类型返回
bool getLong(long & val, string const& key) const:根据Key值获取属性的Value,并将Value值转换成long & 类型返回
bool getULong(unsigned long & val, string const& key) const:根据Key值获取属性的Value,并将Value值转换成unsigned long & 类型返回
bool getBool(bool& val, string const& key) const:根据Key值获取属性的Value,并将Value值转换成bool & 类型返回

[Private]
string const& getProperty2(string const& key) const:内部调用,被getProperty()调用,以获取键值为Key的属性Value值
bool getValType(ValType& val, string const& key) const:内部调用,被get[ValueType]()函数调用,根据Key返回相应数据类型的Value值


[Static]
static void trimLeadingSpace(string& str):删除字符串开头部分的空格字符
static void trimTrailingSpace(string& str):删除字符串结尾部分的空格字符
static void trimAllSpace(string& str):删除字符串两端的空格字符

posted on 2014-10-14 13:37  边城愚者  阅读(220)  评论(0)    收藏  举报