1 // Copyright (C) 2006 Erik Dahlberg
3 // This file is part of LSystem3d.
5 // LSystem3D is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
10 // LSystem3D is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with LSystem3D; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #ifndef XMLSTRUCTURE_H
23 #define XMLSTRUCTURE_H
27 #include <libxml++/document.h>
28 #include <libxml++/nodes/element.h>
29 #include <libxml++/nodes/node.h>
30 #include <libxml++/parsers/domparser.h>
37 * Basic logic for building and parsing xml-structures
58 * Create new document with root node
59 * @param rootName name of root
61 void createDocumentWithRoot(string rootName
);
64 * Add new child to root
65 * @param name name of child
67 void addChildToRoot(string name
);
70 * Add a string as content of current child
71 * @param text the text
73 void addString(string text
);
76 * Add a number as content of current child
77 * @param value the number
79 void addNumber(double value
);
82 * Add attribute to current child
83 * @param name name of attribute
84 * @param value value of attribute
86 void addAttribute(string name
, string value
);
89 * Save document to file
90 * @param path path to file
92 void saveToDisk(string path
);
99 * Load document from file
100 * @param path path to file
102 void loadFromDisk(string path
);
105 * Find all children with the specified name
106 * @param name name of children
107 * @return true if found, else false
109 bool findChild(string name
);
112 * Find next child in current search result list
113 * @return true if found, else false
115 bool findNextChild();
118 * Get content of current child as a string
124 * Get content of current child as a number
130 * Get attribute value of current child
131 * @param name name of attribute
134 string
getAttribute(string name
);
139 xmlpp::Element
*_rootElement
;
140 xmlpp::Element
*_activeElement
;
141 xmlpp::Document
*_activeDocument
;
144 xmlpp::DomParser _parser
;
145 xmlpp::Node::NodeList _activeList
;
146 xmlpp::Node::NodeList::iterator _activeChildInList
;