38 #define G_ACCESS "GXmlNode::operator[](int&)"
39 #define G_SET "GXmlNode::set(int&, GXmlNode&)"
40 #define G_APPEND1 "GXmlNode::append(std::string&)"
41 #define G_APPEND2 "GXmlNode::append(GXmlNode&)"
42 #define G_INSERT "GXmlNode::insert(int&, GXmlNode&)"
43 #define G_REMOVE "GXmlNode::remove(int&)"
44 #define G_ELEMENT1 "GXmlNode* GXmlNode::element(int&)"
45 #define G_ELEMENT2 "GXmlNode* GXmlNode::element(std::string&)"
46 #define G_ELEMENT3 "GXmlNode* GXmlNode::element(std::string&, int&)"
47 #define G_EXTRACT_INDEX "GXmlNode::extract_index(std::string&)"
153 #if defined(G_RANGE_CHECK)
154 if (index < 0 || index >=
size()) {
179 #if defined(G_RANGE_CHECK)
180 if (index < 0 || index >=
size()) {
219 std::string msg =
"Invalid attempt to append root note (GXmlDocument)"
220 " to a XML node. There can only be one root node in"
228 std::string msg =
"Invalid attempt to append a XML node to a text node"
229 " (GXmlText). Nothing can be appended to a text node.";
236 std::string msg =
"Invalid attempt to append a XML node to a processing"
237 " instruction node (GXmlPI). Nothing can be appended"
238 " to a processing instruction node.";
245 std::string msg =
"Invalid attempt to append a XML node to a comment"
246 " node (GXmlComment). Nothing can be appended"
247 " to a processing instruction node.";
252 #if defined(G_RANGE_CHECK)
253 if (index < 0 || index >=
size()) {
292 std::string msg =
"Invalid attempt to append root note (GXmlDocument)"
293 " to a XML node. There can only be one root node in"
301 std::string msg =
"Invalid attempt to append a XML node to a text node"
302 " (GXmlText). Nothing can be appended to a text node.";
309 std::string msg =
"Invalid attempt to append a XML node to a processing"
310 " instruction node (GXmlPI). Nothing can be appended"
311 " to a processing instruction node.";
318 std::string msg =
"Invalid attempt to append a XML node to a comment"
319 " node (GXmlComment). Nothing can be appended"
320 " to a processing instruction node.";
354 std::string msg =
"Invalid attempt to append the text segment \""+
355 segment+
"\" to a text node (GXmlText). Nothing can"
356 " be appended to a text node.";
363 std::string msg =
"Invalid attempt to append a XML node to a processing"
364 " instruction node (GXmlPI). Nothing can be appended"
365 " to a processing instruction node.";
372 std::string msg =
"Invalid attempt to append a XML node to a comment"
373 " node (GXmlComment). Nothing can be appended"
374 " to a processing instruction node.";
412 std::string msg =
"Invalid attempt to append root note (GXmlDocument)"
413 " to a XML node. There can only be one root node in"
421 std::string msg =
"Invalid attempt to append a XML node to a text node"
422 " (GXmlText). Nothing can be appended to a text node.";
429 std::string msg =
"Invalid attempt to append a XML node to a processing"
430 " instruction node (GXmlPI). Nothing can be appended"
431 " to a processing instruction node.";
438 std::string msg =
"Invalid attempt to append a XML node to a comment"
439 " node (GXmlComment). Nothing can be appended"
440 " to a processing instruction node.";
445 #if defined(G_RANGE_CHECK)
453 if (index < 0 || index >=
size()) {
484 #if defined(G_RANGE_CHECK)
485 if (index < 0 || index >=
size()) {
518 int num = node.
size();
524 for (
int i = 0; i < num; ++i) {
554 while (parent != NULL) {
568 parent = parent->
parent();
590 for (
int i = 0; i <
m_nodes.size(); ++i) {
615 for (
int i = 0; i <
m_nodes.size(); ++i) {
617 if (static_cast<GXmlElement*>(
m_nodes[i])->name() == name) {
662 if (index < 0 || index >=
elements()) {
670 for (
int i = 0; i <
m_nodes.size(); ++i) {
673 if (elements == index) {
746 for (
int i = 0; i < tags.size(); ++i) {
754 if (n < 1 || index < 0 || index >= n) {
760 element = current->
element(tag, index);
764 if (current == NULL) {
814 const int& index)
const
823 for (
int i = 0; i <
m_nodes.size(); ++i) {
826 if (src->
name() == name) {
828 if (elements == index) {
839 std::string msg =
"XML node has no element with name \""+name+
840 "\". Please verify the XML format.";
845 if (index < 0 || index >= n) {
864 std::string result =
print(chatter, 0);
905 for (
int i = 0; i < node.
m_nodes.size(); ++i) {
924 for (
int i = 0; i <
m_nodes.size(); ++i) {
957 size_t start = tag.find_first_of(
"[");
958 if (start != std::string::npos) {
959 size_t stop = tag.find_first_of(
"]", start);
960 if (stop == std::string::npos) {
961 std::string msg =
"Tag specifier \""+tag+
"\" is missing "
966 size_t length = stop - start - 1;
968 std::string msg =
"Index value is missing for \""+tag+
"\".";
973 tag = tag.substr(0, start);
Abstract XML node base class.
GXmlNode * parent(void) const
Return parent XML node.
GXmlNode & operator=(const GXmlNode &node)
Assignment operator.
GFilename filename(void) const
Return filename of XML file.
std::vector< GXmlNode * > m_nodes
Pointer to child nodes.
XML element node class interface definition.
virtual GXmlNode * set(const int &index, const GXmlNode &node)
Set XML child node.
void init_members(void)
Initialise class members.
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.
virtual int elements(void) const
Return number of GXMLElement children of node.
void free_members(void)
Delete class members.
const std::string & name(void) const
Return XML element name.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
virtual void extend(const GXmlNode &node)
Append all XML child nodes from another XML node.
virtual GXmlNode * insert(const int &index, const GXmlNode &node)
Insert XML child node.
virtual int size(void) const
Return number of child nodes.
virtual GXmlNode * clone(void) const =0
Clones object.
virtual void reserve(const int &num)
Reserve space for child nodes.
virtual NodeType type(void) const =0
XML document node class interface definition.
GXmlNode * m_parent
Pointer on parent node.
void copy_members(const GXmlNode &node)
Copy class members.
virtual std::string print(const GChatter &chatter=NORMAL, const int &indent=0) const =0
virtual GXmlElement * element(const int &index)
Return pointer to GXMLElement child.
GXmlNode * operator[](const int &index)
Return pointer to XML child node.
virtual bool is_empty(void) const
Signals if node has no child nodes.
Exception handler interface definition.
int extract_index(std::string &tag) const
Extract index from tag.
int toint(const std::string &arg)
Convert string into integer value.
const GFilename & filename(void) const
Return filename.
virtual GXmlNode * append(const GXmlNode &node)
Append XML child node.
Abstract XML node base class interface definition.
GXmlNode(void)
Void constructor.
virtual ~GXmlNode(void)
Destructor.
virtual void remove(const int &index)
Remove XML child node.