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

📄 xmlconfig2.h

📁 跨操作系统的微型中间件
💻 H
字号:
#ifndef __XML__CONFIG__2__
#define  __XML__CONFIG__2__

#ifdef __Win32__
#pragma warning(disable: 4786)
#endif

#include <vector>
#include <string>
#include "OSHeaders.h"
#include "XMLNode.h"
#include "OSMutex.h"
//#include "GlobalStruct.h"
#include "Globle.h"

struct AclNode{
	string strIp;
	vector <string> strDir;
};

class XMLDoc;
class CXMLConfigMng;
//This class only can be used by CXMLConfigMng
class CXMLConfig
{
	friend class CXMLConfigMng;
private:
	CXMLConfig(const string& strFileName);
	~CXMLConfig();
	
	Bool ReadConfigItem();
	Bool ReadConfigItemForRTSPClient();
	Bool LoadFile();
	
	inline Bool GetItemValue(XMLNode* pNode, const string& strKey, UInt32 *pdwValue, Bool IsDynUpdate=TRUE);
	inline Bool GetItemValue(XMLNode* pNode, const string& strKey, char *pcValue, Bool IsDynUpdate=TRUE);

	Bool GetContent(const string& strPos, string& outVal, Bool isDynUpdate=TRUE);
	Bool GetContent(const string& strPos, UInt32& outVal, Bool isDynUpdate=TRUE);
	
	Bool GetProperty(const string& strPos, string& outVal, Bool isDynUpdate=TRUE);
	Bool GetProperty(const string& strPos, UInt32& outVal, Bool isDynUpdate=TRUE);
	Bool GetProperty(const string& strPos, vector<SIPandPort>&outVec, Bool isDynUpdate=TRUE);
	Bool GetProperty(const string& strPos, SIPandPort &outIpPort, Bool isDynUpdate=TRUE);
	
	void SeperateString(const string& inStr, vector<string>& outVec, const string Delimiter="/");
	void TransPathDelimiter( string& strPath );

private:
	string m_strFileName;
	XMLDoc *m_pDoc;
	
	Bool	m_Isinit;
	Bool	m_IsFirstRead;
};

class CXMLConfigMng
{
public:

	static CXMLConfigMng* GetInst(const char *pFileName = NULL);
	static Bool DelInst();
	//If the Xml File modified
	static Bool IsModified();

	//Read item from Xml File
	Bool ReadDataFromFile(Bool isRTSPClient = FALSE);
private:
	CXMLConfigMng(const string& strXmlFile);
	~CXMLConfigMng();
	
	Bool LoadXmlConfig();
private:
	static CXMLConfigMng	*m_Inst;

	OSMutex		m_MutexRun;

	CXMLConfig *m_pXmlConfig;
	
	string m_strXmlFile; //Xml file Name
	time_t m_LastModTime; //last modified time of the XMl file
};


#endif

⌨️ 快捷键说明

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