8 #include <boost/shared_ptr.hpp>
10 #include "exceptions.h"
23 XMLNode (xmlpp::Node const * node);
26 std::string string_node (std::string);
27 std::string optional_string_node (std::string);
28 ContentKind kind_node (std::string);
29 Fraction fraction_node (std::string);
30 int64_t int64_node (std::string);
31 void ignore_node (std::string);
35 boost::shared_ptr<T> sub_node (std::string name) {
36 return boost::shared_ptr<T> (new T (xml_node (name)));
40 boost::shared_ptr<T> optional_sub_node (std::string name) {
41 std::list<xmlpp::Node*> n = xml_nodes (name);
43 throw XMLError ("duplicate XML tag");
44 } else if (n.empty ()) {
45 return boost::shared_ptr<T> ();
48 return boost::shared_ptr<T> (new T (n.front ()));
52 std::list<boost::shared_ptr<T> > sub_nodes (std::string name, std::string sub) {
53 XMLNode p (xml_node (name));
54 std::list<xmlpp::Node*> n = p.xml_nodes (sub);
55 std::list<boost::shared_ptr<T> > r;
56 for (typename std::list<xmlpp::Node*>::iterator i = n.begin(); i != n.end(); ++i) {
57 r.push_back (boost::shared_ptr<T> (new T (*i)));
62 xmlpp::Node const * _node;
65 xmlpp::Node* xml_node (std::string);
66 std::list<xmlpp::Node*> xml_nodes (std::string);
67 std::list<Glib::ustring> _taken;
70 class XMLFile : public XMLNode
73 XMLFile (std::string file, std::string root_name);
77 xmlpp::DomParser* _parser;