7 #include <boost/shared_ptr.hpp>
9 #include "exceptions.h"
22 XMLNode (xmlpp::Node const * node);
25 std::string string_node (std::string);
26 std::string optional_string_node (std::string);
27 ContentKind kind_node (std::string);
28 Fraction fraction_node (std::string);
29 int64_t int64_node (std::string);
30 void ignore_node (std::string);
34 boost::shared_ptr<T> sub_node (std::string name) {
35 return boost::shared_ptr<T> (new T (xml_node (name)));
39 boost::shared_ptr<T> optional_sub_node (std::string name) {
40 std::list<xmlpp::Node*> n = xml_nodes (name);
42 throw XMLError ("duplicate XML tag");
43 } else if (n.empty ()) {
44 return boost::shared_ptr<T> ();
47 return boost::shared_ptr<T> (new T (n.front ()));
51 std::list<boost::shared_ptr<T> > sub_nodes (std::string name, std::string sub) {
52 XMLNode p (xml_node (name));
53 std::list<xmlpp::Node*> n = p.xml_nodes (sub);
54 std::list<boost::shared_ptr<T> > r;
55 for (typename std::list<xmlpp::Node*>::iterator i = n.begin(); i != n.end(); ++i) {
56 r.push_back (boost::shared_ptr<T> (new T (*i)));
61 xmlpp::Node const * _node;
64 xmlpp::Node* xml_node (std::string);
65 std::list<xmlpp::Node*> xml_nodes (std::string);
66 std::list<Glib::ustring> _taken;
69 class XMLFile : public XMLNode
72 XMLFile (std::string file, std::string root_name);
76 xmlpp::DomParser* _parser;