20XMLParser::XMLParser() {}
22XMLParser::~XMLParser() {}
24rapidxml::xml_node<>* XMLParser::AppendNode(rapidxml::xml_document<>& doc,
25 rapidxml::xml_node<>* parentNode,
27 rapidxml::node_type nodeType)
29 rapidxml::xml_node<>* node = doc.allocate_node(nodeType, name);
30 parentNode->append_node(node);
34void XMLParser::SetNodeValue(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* node, wxString value)
36 node->value(doc.allocate_string(value.mb_str()));
39void XMLParser::SetNodeValue(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* node,
int value)
41 node->value(doc.allocate_string(wxString::Format(
"%d", value).mb_str()));
44void XMLParser::SetNodeValue(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* node,
double value)
46 node->value(doc.allocate_string(wxString::FromCDouble(value, 13).mb_str()));
49void XMLParser::SetNodeAttribute(rapidxml::xml_document<>& doc,
50 rapidxml::xml_node<>* node,
54 node->append_attribute(doc.allocate_attribute(atrName, doc.allocate_string(value.mb_str())));
57void XMLParser::SetNodeAttribute(rapidxml::xml_document<>& doc,
58 rapidxml::xml_node<>* node,
62 node->append_attribute(
63 doc.allocate_attribute(atrName, doc.allocate_string(wxString::Format(
"%d", value).mb_str())));
66void XMLParser::SetNodeAttribute(rapidxml::xml_document<>& doc,
67 rapidxml::xml_node<>* node,
71 node->append_attribute(
72 doc.allocate_attribute(atrName, doc.allocate_string(wxString::FromCDouble(value, 13).mb_str())));
75double XMLParser::GetNodeValueDouble(rapidxml::xml_node<>* parent,
const char* nodeName)
79 auto node = parent->first_node(nodeName);
80 if(node) wxString(node->value()).ToCDouble(&dValue);
85int XMLParser::GetNodeValueInt(rapidxml::xml_node<>* parent,
const char* nodeName)
89 auto node = parent->first_node(nodeName);
90 if(node) wxString(node->value()).ToCLong(&iValue);
95int XMLParser::GetAttributeValueInt(rapidxml::xml_node<>* parent,
const char* nodeName,
const char* atrName)
99 auto node = parent->first_node(nodeName);
101 auto atr = node->first_attribute(atrName);
102 if(atr) wxString(atr->value()).ToCLong(&iValue);
108int XMLParser::GetAttributeValueInt(rapidxml::xml_node<>* node,
const char* atrName)
111 auto atr = node->first_attribute(atrName);
112 if(!atr)
return false;
113 wxString(atr->value()).ToCLong(&intValue);
114 return (
int)intValue;