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

📄 wp_exmlnode.h

📁 电力故障信息采集,主要是针对南自的保护装置,这个程序用在Linux操作系统下
💻 H
字号:

#ifndef __WP_EXML_NODE_H__
#define __WP_EXML_NODE_H__

#include "WP_EXMLGlobal.h"
#include "WP_EXMLAttribute.h"

class EXMLAttribute;

/// XML节点包装类
class WP_EXMLNode
{
public:
    /// 附加一个子节点,附加后,返回新增节点
    WP_EXMLNode* AddChild(const char* pszName, const char* pszValue);
    /// 附加一个属性,附加后,返回新增属性
    WP_EXMLAttribute* AddAttribute(const char* pszName, const char* pszValue);


    /// 附加一个子节点,附加后,用户不具有对pChild的管理权
    void AddChild(WP_EXMLNode* pChild);
    /// 移除一个子节点,移除后,用户不具有对pChild的使用权
    void RemoveChild(WP_EXMLNode* pChild);

    /// 附加一个属性,用户不具有对pAttr的管理权
    void AddAttribute(WP_EXMLAttribute* pAttr);
    /// 移除一个属性,用户不具有对pAttr的使用权
    void RemoveAttribute(WP_EXMLAttribute* pAttr);


    /// 设置节点名
    void SetName(const char* pszName);
    /// 设置节点值
    void SetValue(const char* pszValue);

    /// 取节点名
    void GetName(std::string& strName);
    const char* GetName();
    /// 取节点值
    void GetValue(std::string& strValue);
    const char* GetValue();

    /// 根据索引取子节点
    WP_EXMLNode* GetChildNode(long index);
    WP_EXMLNode* FindChild(const char* szQuery);

    /// 根据索引取属性
    WP_EXMLAttribute* GetAttribute(long index);
    WP_EXMLAttribute* FindAttribute(const char* pszQuery);

    /// 取子节点数
    long GetChildCount();
    /// 取属性数
    long GetAttributeCount();

    const char *GetXML(int &nFormatTabs);

	/// nFormatTabs: 用于格式化控制生成格式美观的XML数据
    void ToXML(int &nFormatTabs);

public:
    WP_EXMLNode();
    WP_EXMLNode(const char* psName, const char* pszValue);
    virtual ~WP_EXMLNode();

private:
    /// 节点名
    std::string m_strName;
    /// 节点值
    std::string m_strValue;

    /// 子节点组
    std::vector<WP_EXMLNode*> m_Childs;
    /// 属性组
    std::vector<WP_EXMLAttribute*> m_Attributes;

    /// 节点的XML表达
    std::string m_strXML;
};

#endif // #define __WP_EXML_NODE_H__

⌨️ 快捷键说明

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