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
);
98 * Load document from file
99 * @param path path to file
101 void loadFromDisk(string path
);
104 * Find all children with the specified name
105 * @param name name of children
106 * @return true if found, else false
108 bool findChild(string name
);
111 * Find next child in current search result list
112 * @return true if found, else false
114 bool findNextChild();
117 * Get content of current child as a string
123 * Get content of current child as a number
129 * Get attribute value of current child
130 * @param name name of attribute
133 string
getAttribute(string name
);
137 * Convert double to string
138 * @param doubleValue the double value
139 * @return the corresponding string
141 string
doubleToString(double doubleValue
);
146 xmlpp::Element
*_rootElement
;
147 xmlpp::Element
*_activeElement
;
148 xmlpp::Document
*_activeDocument
;
151 xmlpp::DomParser _parser
;
152 xmlpp::Node::NodeList _activeList
;
153 xmlpp::Node::NodeList::iterator _activeChildInList
;