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

📄 wp_exmlattribute.cpp

📁 电力故障信息采集,主要是针对南自的保护装置,这个程序用在Linux操作系统下
💻 CPP
字号:
#include "WP_EXMLAttribute.h"#include "WP_Utility.h"WP_EXMLAttribute::WP_EXMLAttribute(){    m_strName = "";    m_strXML = "";}WP_EXMLAttribute::WP_EXMLAttribute(const char* pszName, const char* pszValue){    m_strXML = "";    m_strName = pszName;    m_strValue = pszValue;}WP_EXMLAttribute::~WP_EXMLAttribute(){}void WP_EXMLAttribute::SetValue(const char *pszValue){    m_strValue = pszValue;    m_strXML = "";}void WP_EXMLAttribute::SetName(const char *pszName){    m_strName = pszName;    m_strXML = "";}void WP_EXMLAttribute::GetName(std::string &strName){    strName = m_strName;}void WP_EXMLAttribute::GetValue(std::string &strValue){    strValue = m_strValue;}const char* WP_EXMLAttribute::GetValue(){    if (m_strValue.empty())        return "";    return m_strValue.c_str();}const char* WP_EXMLAttribute::GetName(){    if (m_strName.empty())        return "";    return m_strName.c_str();}void WP_EXMLAttribute::GetXML(std::string &strXML){    if( m_strXML.length() < 1 )        ToXML();    strXML = m_strXML;}const char* WP_EXMLAttribute::GetXML(){    if( m_strXML.length() < 1 )        ToXML();    return m_strXML.c_str();}void WP_EXMLAttribute::ToXML(){    //= 如果属性值中出现单引号,则用双引号封闭属性值,    //= 出现双引号,则用单引号封闭属性值    bool occur_single = (NULL!=strchr(m_strValue.c_str(), '\''));    m_strXML = m_strName;    if (occur_single)        m_strXML += "=\"";    else        m_strXML += "=\'";    std::string strValue = m_strValue;    //= 替换存在先后顺序    replace_all_distinct(strValue, "&", "&amp;");    replace_all_distinct(strValue, "<", "&lt;");    replace_all_distinct(strValue, ">", "&gt;");    m_strXML += strValue;    if (occur_single)    m_strXML += "\"";    else    m_strXML += "\'";}

⌨️ 快捷键说明

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