Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
XMLParser Class Reference

XML parser to save and open project and control files. More...

#include <XMLParser.h>

Static Public Member Functions

static rapidxml::xml_node * AppendNode (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *parentNode, const char *name, rapidxml::node_type nodeType=rapidxml::node_element)
 
static void SetNodeValue (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *node, wxString value)
 
static void SetNodeValue (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *node, int value)
 
static void SetNodeValue (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *node, double value)
 
static void SetNodeAttribute (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *node, const char *atrName, wxString value)
 
static void SetNodeAttribute (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *node, const char *atrName, int value)
 
static void SetNodeAttribute (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *node, const char *atrName, double value)
 
static double GetNodeValueDouble (rapidxml::xml_node<> *parent, const char *nodeName)
 
static int GetNodeValueInt (rapidxml::xml_node<> *parent, const char *nodeName)
 
static int GetAttributeValueInt (rapidxml::xml_node<> *parent, const char *nodeName, const char *atrName)
 
static int GetAttributeValueInt (rapidxml::xml_node<> *node, const char *atrName)
 

Detailed Description

XML parser to save and open project and control files.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
08/01/2018

Definition at line 35 of file XMLParser.h.

Constructor & Destructor Documentation

◆ XMLParser()

XMLParser::XMLParser ( )

Definition at line 20 of file XMLParser.cpp.

20{}

◆ ~XMLParser()

XMLParser::~XMLParser ( )

Definition at line 22 of file XMLParser.cpp.

22{}

Member Function Documentation

◆ AppendNode()

rapidxml::xml_node * XMLParser::AppendNode ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  parentNode,
const char *  name,
rapidxml::node_type  nodeType = rapidxml::node_element 
)
static

Definition at line 24 of file XMLParser.cpp.

28{
29 rapidxml::xml_node<>* node = doc.allocate_node(nodeType, name);
30 parentNode->append_node(node);
31 return node;
32}

◆ GetAttributeValueInt() [1/2]

int XMLParser::GetAttributeValueInt ( rapidxml::xml_node<> *  node,
const char *  atrName 
)
static

Definition at line 108 of file XMLParser.cpp.

109{
110 long intValue;
111 auto atr = node->first_attribute(atrName);
112 if(!atr) return false;
113 wxString(atr->value()).ToCLong(&intValue);
114 return (int)intValue;
115}

◆ GetAttributeValueInt() [2/2]

int XMLParser::GetAttributeValueInt ( rapidxml::xml_node<> *  parent,
const char *  nodeName,
const char *  atrName 
)
static

Definition at line 95 of file XMLParser.cpp.

96{
97 long iValue = -1;
98 if(parent) {
99 auto node = parent->first_node(nodeName);
100 if(node) {
101 auto atr = node->first_attribute(atrName);
102 if(atr) wxString(atr->value()).ToCLong(&iValue);
103 }
104 }
105 return (int)iValue;
106}

◆ GetNodeValueDouble()

double XMLParser::GetNodeValueDouble ( rapidxml::xml_node<> *  parent,
const char *  nodeName 
)
static

Definition at line 75 of file XMLParser.cpp.

76{
77 double dValue = 0.0;
78 if(parent) {
79 auto node = parent->first_node(nodeName);
80 if(node) wxString(node->value()).ToCDouble(&dValue);
81 }
82 return dValue;
83}

◆ GetNodeValueInt()

int XMLParser::GetNodeValueInt ( rapidxml::xml_node<> *  parent,
const char *  nodeName 
)
static

Definition at line 85 of file XMLParser.cpp.

86{
87 long iValue = -1;
88 if(parent) {
89 auto node = parent->first_node(nodeName);
90 if(node) wxString(node->value()).ToCLong(&iValue);
91 }
92 return (int)iValue;
93}

◆ SetNodeAttribute() [1/3]

void XMLParser::SetNodeAttribute ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  node,
const char *  atrName,
double  value 
)
static

Definition at line 66 of file XMLParser.cpp.

70{
71 node->append_attribute(
72 doc.allocate_attribute(atrName, doc.allocate_string(wxString::FromCDouble(value, 13).mb_str())));
73}

◆ SetNodeAttribute() [2/3]

void XMLParser::SetNodeAttribute ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  node,
const char *  atrName,
int  value 
)
static

Definition at line 57 of file XMLParser.cpp.

61{
62 node->append_attribute(
63 doc.allocate_attribute(atrName, doc.allocate_string(wxString::Format("%d", value).mb_str())));
64}

◆ SetNodeAttribute() [3/3]

void XMLParser::SetNodeAttribute ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  node,
const char *  atrName,
wxString  value 
)
static

Definition at line 49 of file XMLParser.cpp.

53{
54 node->append_attribute(doc.allocate_attribute(atrName, doc.allocate_string(value.mb_str())));
55}

◆ SetNodeValue() [1/3]

void XMLParser::SetNodeValue ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  node,
double  value 
)
static

Definition at line 44 of file XMLParser.cpp.

45{
46 node->value(doc.allocate_string(wxString::FromCDouble(value, 13).mb_str()));
47}

◆ SetNodeValue() [2/3]

void XMLParser::SetNodeValue ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  node,
int  value 
)
static

Definition at line 39 of file XMLParser.cpp.

40{
41 node->value(doc.allocate_string(wxString::Format("%d", value).mb_str()));
42}

◆ SetNodeValue() [3/3]

void XMLParser::SetNodeValue ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  node,
wxString  value 
)
static

Definition at line 34 of file XMLParser.cpp.

35{
36 node->value(doc.allocate_string(value.mb_str()));
37}

The documentation for this class was generated from the following files: