www.pudn.com > antispam-addin.rar > configcontrol.hxx


#ifndef GET_CONFIG_H_ 
#define GET_CONFIG_H_ 
 
#include "unihead.hxx" 
 
#define LINE_LEN_MAX 1024 
 
#define CONFIG_FILE_PATH_ERROE    1 
#define CONFIG_FILE_OPEN_ERROR    2 
#define CONFIG_FILE_CLOSE_ERROR   3 
#define CONFIG_FILE_OPERATE_ERROR 4 
#define CONFIG_GROUP_EMPTY        10 
#define CONFIG_GROUP_NOTFOUND     11 
#define CONFIG_ITEM_EMPTY         20 
#define CONFIG_ITEM_NOTFOUND      21 
#define CONFIG_VALUE_NOTFOUND     30 
#define CONFIG_VALUE_EMPTY        100 
 
 
 
class ConfigControl 
{ 
public: 
	ConfigControl(); 
	virtual ~ConfigControl(); 
 
public:	 
	int   OpenConfig(const char *filename);//打开文件 
	int   GetConfigValue(const char *group, const char * item,char *value,int valuelen);//读取一条信息 
	int   GetConfigValueEx(const char *filename,const char *group, const char * item,char *value,int valuelen);//读取一条信息 
	int   CloseConfig();//关闭文件 
	int   GetErrorCode();//获得最后出错标记 
 
	char *righttrim( char *szSource );////清空字符串右边的空格 
	char *lefttrim( char *szSource );////清空字符串左边的空格 
	char *trim( char *szSource );////清空字符串两边的空格 
 
	bool  NextLine(); 
	int   GetLine(char *line);//读取文件中的一行信息 
 
private:	 
	 
	int   GetGroup(const char *group,const char *line);//判断当前行是不是group所在行 
	int   GetItem(const char *item,const char *line);//判断当前行是不是item所在行 
	int   GetValue( char *strdest,const char *line,int valuelen);//获得本行中的value; 
	int   IsGroup(char *line);//判断该行是否有可能包含一个group 
	void  UpperStr(char *string); 
	 
	FILE *stream_read; 
	int  errorcode; 
 
	fpos_t fNextPos; 
	bool bLineEnd; 
}; 
 
 
#endif//GET_CONFIG_H_