⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 config_file_map.h

📁 股票分析源代码
💻 H
字号:
#ifndef __GNU_CONFIG_FILE_MAP_H__
#define __GNU_CONFIG_FILE_MAP_H__

#include <vector>
#include <map>
#include <string>
#include <cstdio>

#include <ace/Refcounted_Auto_Ptr.h>
#include <ace/Null_Mutex.h>
#include <ace/Configuration.h>

#include "gnu/app_config.h"

namespace gnu
{
	
struct ConfigFileItem
{
	std::string key;	
	std::string value;	
};

typedef std::vector<ConfigFileItem> VectConfigFileItem;
typedef ACE_Refcounted_Auto_Ptr<VectConfigFileItem,ACE_Null_Mutex> VectConfigFileItemPtr;
typedef ACE_Refcounted_Auto_Ptr<ACE_Configuration_Heap,ACE_Null_Mutex> ACE_Configuration_HeapPtr;

bool ConfigFileItemSort_key (const ConfigFileItem& data1,
	const ConfigFileItem& data2);

bool ConfigFileItemSort_value (const ConfigFileItem& data1,
	const ConfigFileItem& data2);
	
class ConfigFileMap
{

public:	
	ConfigFileMap();
	~ConfigFileMap();
	
	std::string get_conf_file();
	void set_conf_file(const std::string& str_file_name);
	bool load_file(const char* p_ch_conf_file_name);	
	bool reload();
	bool save();
	
	bool remove(const std::string& str_section,const std::string& str_key);
	bool remove_section(const std::string& str_section);
	
	bool get_sections(std::vector<std::string>& vect_section);	
	bool get_section_items(VectConfigFileItem& vect_item,const std::string& str_section);
	
	bool get_value(const std::string& str_section,
		const std::string& str_key,std::string& str_value);
	bool get_value(const std::string& str_section,
		const std::string& str_key,int& i_value);
	bool get_value(const std::string& str_section,
		const std::string& str_key,long& l_value);
	bool get_value(const std::string& str_section,
		const std::string& str_key,float& f_value);
	bool get_value(const std::string& str_section,
		const std::string& str_key,double& d_value);
	
	bool get_value(const std::string& str_section,
		const std::string& str_key,std::string& str_value,
		const std::string& str_default_value);
	bool get_value(const std::string& str_section,
		const std::string& str_key,int& i_value,
		const int i_default_value);
	bool get_value(const std::string& str_section,
		const std::string& str_key,long& l_value,
		const long l_default_value);
	bool get_value(const std::string& str_section,
		const std::string& str_key,float& f_value,
		const float f_default_value);
	bool get_value(const std::string& str_section,
		const std::string& str_key,double& d_value,
		const double d_default_value);
		
	bool set_value(const std::string& str_section,
		const std::string& str_key,const std::string& str_value);
	bool set_value(const std::string& str_section,
		const std::string& str_key,const int& i_value);
	bool set_value(const std::string& str_section,
		const std::string& str_key,const long& l_value);
	bool set_value(const std::string& str_section,
		const std::string& str_key,const float& f_value);
	bool set_value(const std::string& str_section,
		const std::string& str_key,const double& d_value);


protected :
	ACE_Configuration_HeapPtr m_config_heap_ptr;
	
private :
	ConfigFileMap(const ConfigFileMap& other);
	ConfigFileMap& operator=(const ConfigFileMap& other);
	
private :		
	std::string m_str_section;	
	std::string m_str_conf_filename;
	
	bool m_is_changed;
};



} // namespace gnu
#endif  // #ifndef __GNU_CONFIG_FILE_MAP_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -