20 #ifndef LIBCXML_CXML_H
21 #define LIBCXML_CXML_H
23 #include <boost/shared_ptr.hpp>
24 #include <boost/optional.hpp>
25 #include <boost/filesystem.hpp>
26 #include <boost/algorithm/string/erase.hpp>
45 class Error :
public std::exception
51 Error (std::string
const & message) : _message (message) {}
59 char const *
what ()
const throw () {
60 return _message.c_str ();
78 Node (xmlpp::Node* node);
80 std::string name ()
const;
104 std::string string_child (std::string c)
const;
105 boost::optional<std::string> optional_string_child (std::string)
const;
107 bool bool_child (std::string)
const;
108 boost::optional<bool> optional_bool_child (std::string)
const;
111 T number_child (std::string c)
const
113 std::string s = string_child (c);
114 boost::erase_all (s,
" ");
116 t.imbue (std::locale::classic ());
124 boost::optional<T> optional_number_child (std::string c)
const
126 boost::optional<std::string> s = optional_string_child (c);
128 return boost::optional<T> ();
131 std::string t = s.get ();
132 boost::erase_all (t,
" ");
134 u.imbue (std::locale::classic ());
153 std::string string_attribute (std::string)
const;
154 boost::optional<std::string> optional_string_attribute (std::string)
const;
156 bool bool_attribute (std::string)
const;
157 boost::optional<bool> optional_bool_attribute (std::string)
const;
160 T number_attribute (std::string c)
const
162 std::string s = string_attribute (c);
163 boost::erase_all (s,
" ");
165 t.imbue (std::locale::classic ());
173 boost::optional<T> optional_number_attribute (std::string c)
const
175 boost::optional<std::string> s = optional_string_attribute (c);
177 return boost::optional<T> ();
180 std::string t = s.get ();
181 boost::erase_all (t,
" ");
183 u.imbue (std::locale::classic ());
199 boost::shared_ptr<Node> node_child (std::string)
const;
200 boost::shared_ptr<Node> optional_node_child (std::string)
const;
202 std::list<boost::shared_ptr<Node> > node_children (std::string)
const;
204 xmlpp::Node* node ()
const {
212 mutable std::list<std::string> _taken;
215 typedef boost::shared_ptr<cxml::Node> NodePtr;
216 typedef boost::shared_ptr<const cxml::Node> ConstNodePtr;
223 Document (std::string root_name, boost::filesystem::path);
227 void read_file (boost::filesystem::path);
228 void read_stream (std::istream &);
229 void read_string (std::string);
231 std::string root_name ()
const {
236 void take_root_node ();
238 xmlpp::DomParser* _parser;
239 std::string _root_name;
void ignore_child(std::string) const
Definition: cxml.cc:139
std::string namespace_uri() const
Definition: cxml.cc:222
A wrapper for a xmlpp::Node which simplifies parsing.
Definition: cxml.h:69
~Error()
Definition: cxml.h:54
std::string content() const
Definition: cxml.cc:206
std::string namespace_prefix() const
Definition: cxml.cc:228
Error(std::string const &message)
Definition: cxml.h:51
An error.
Definition: cxml.h:45
void done() const
Definition: cxml.cc:195
char const * what() const
Definition: cxml.h:59