cbasenode.h

来自「液晶电视完整代码可实现人机界面」· C头文件 代码 · 共 66 行

H
66
字号
#ifndef _CBASENODE_
#define _CBASENODE_
///////////////////////////////////////////////////////////////////////////////////
//引用libxml2的头文件
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/encoding.h>
///////////////////////////////////////////////////////////////////////////////////
#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#define NODELIST xmlNodePtr
#define NODE xmlNodePtr
#define MAXATTRVALUELEN 256 + 1

///////////////////////////////////////////////////////////////////////////////////
//
class CBaseNode 
{
private:
	unsigned char outValue[MAXATTRVALUELEN];
	int outValueLen ;
	bool m_bReady;
	xmlDocPtr m_Doc ;// the xml docuement handle
	// -----------------------------------------------------------------------
	//  Hidden constructors and operators
	// -----------------------------------------------------------------------
	void operator=(const CBaseNode&){};
	CBaseNode(const CBaseNode&){};

	void CloseXMLDoc();

public:
	CBaseNode(){};
	~CBaseNode() {CloseXMLDoc();};
	
	void OpenXMLDoc(const char*  xmlFileName);

	NODE GetRootNode()
	{
		return xmlDocGetRootElement(m_Doc);
	};
	
	bool IsRightNode(NODE currentNode, const char* nodeName)
	{
		bool bRetval = false;
		if(xmlStrcmp(currentNode->name, (xmlChar *) nodeName) == 0) 
		{
			bRetval = true;
		}
		return bRetval;
	}
	void GetAttributeValue(NODE currentNode, const char* attrName, char* attrValue, const char* delaultValue);

	CBaseNode(const char*  xmlFileName)
	{
		OpenXMLDoc(xmlFileName);
	};
	
	bool IsReady(){return m_bReady;};
	
};
#endif

⌨️ 快捷键说明

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