Definition at line 43 of file XML.h.
◆ XNode()
Definition at line 123 of file XML.cpp.
123 {
124 this->parent = NULL;
125 this->name = "";
126 this->value = "";
127 this->attributes = std::vector<XAttrib>();
128 this->children = std::vector<XNode>();
129}
◆ getAttribute()
const XAttrib & XNode::getAttribute |
( |
const char * |
name | ) |
const |
Definition at line 148 of file XML.cpp.
148 {
149 for (unsigned int i = 0; i < this->attributes.size(); i++) {
150 if (strcmp(this->attributes.at(i).name.c_str(), name) == 0) return this->attributes.at(i);
151 }
152
153 printf("Warning: Attribute [%s] not found.", name);
154 throw -1;
155}
◆ getChild()
const XNode & XNode::getChild |
( |
const char * |
name | ) |
const |
Definition at line 183 of file XML.cpp.
183 {
184 for (unsigned int i = 0; i < this->children.size(); i++) {
185 if (strcmp(this->children[i].name.c_str(), name) == 0) return this->children[i];
186 }
187
188 printf("Error: Node [%s] not found.\n", name);
189 throw -1;
190}
◆ getNode()
const XNode & XNode::getNode |
( |
const char * |
name | ) |
const |
Definition at line 139 of file XML.cpp.
139 {
140 const XNode* res = this->_getNode(name);
141 if (!res) {
142 printf("Error: Node [%s] not found.", name);
143 throw -1;
144 }
145 return *res;
146}
◆ getNodeByAttribute()
const XNode & XNode::getNodeByAttribute |
( |
const char * |
node_name, |
|
|
const char * |
attrib_name, |
|
|
const char * |
attrib_value |
|
) |
| const |
Definition at line 164 of file XML.cpp.
164 {
165 const XNode* res = this->_getNodeByAttribute(node_name, attrib_name, attrib_value);
166 if (!res) {
167 printf("Warning: Node with ");
168 if (node_name != NULL) printf("name \"%s\" and ", node_name);
169 printf("attribute [");
170 printf("%s=", attrib_name == NULL ? "\"\"" : attrib_name);
171 printf("%s", attrib_value == NULL ? "\"\"" : attrib_value);
172 printf("] not found.\n");
173 throw -1;
174 }
175 return *res;
176}
◆ hasAttribute()
bool XNode::hasAttribute |
( |
const char * |
name | ) |
const |
Definition at line 157 of file XML.cpp.
157 {
158 for (const auto & attribute : this->attributes) {
159 if (strcmp(attribute.name.c_str(), name) == 0) return true;
160 }
161 return false;
162}
◆ hasChild()
bool XNode::hasChild |
( |
const char * |
name | ) |
const |
Definition at line 192 of file XML.cpp.
192 {
193 for (const auto & child : this->children) {
194 if (strcmp(child.name.c_str(), name) == 0) return true;
195 }
196 return false;
197}
◆ hasNodeByAttribute()
bool XNode::hasNodeByAttribute |
( |
const char * |
node_name, |
|
|
const char * |
attrib_name, |
|
|
const char * |
attrib_value |
|
) |
| const |
Definition at line 178 of file XML.cpp.
178 {
179 const XNode* res = this->_getNodeByAttribute(node_name, attrib_name, attrib_value);
180 return res != nullptr;
181}
◆ print()
void XNode::print |
( |
| ) |
const |
Definition at line 131 of file XML.cpp.
132{
133 printf("%s: [%s] ", name.c_str(), value.c_str());
134 for (unsigned int i = 0; i < this->attributes.size(); i++)
135 printf("%s ", this->attributes.at(i).toString().c_str());
136 printf("\n");
137}
◆ attributes
std::vector<XAttrib> XNode::attributes |
Definition at line 55 of file XML.h.
◆ children
std::vector<XNode> XNode::children |
Definition at line 56 of file XML.h.
◆ name
Definition at line 52 of file XML.h.
◆ parent
Definition at line 50 of file XML.h.
◆ raw
Definition at line 54 of file XML.h.
◆ sub_index
int XNode::sub_index = -1 |
Definition at line 58 of file XML.h.
◆ value
Definition at line 53 of file XML.h.
The documentation for this class was generated from the following files: