8 #include <boost/shared_ptr.hpp>
10 #include "exceptions.h"
24 XMLNode (xmlpp::Node const * node);
27 std::string string_node (std::string);
28 std::string optional_string_node (std::string);
29 ContentKind kind_node (std::string);
30 Fraction fraction_node (std::string);
31 int64_t int64_node (std::string);
32 int64_t optional_int64_node (std::string);
33 float float_node (std::string);
34 void ignore_node (std::string);
37 Time time_attribute (std::string);
38 float float_attribute (std::string);
39 std::string string_attribute (std::string);
40 int64_t int64_attribute (std::string);
41 int64_t optional_int64_attribute (std::string);
43 std::string content ();
46 boost::shared_ptr<T> sub_node (std::string name) {
47 return boost::shared_ptr<T> (new T (xml_node (name)));
51 boost::shared_ptr<T> optional_sub_node (std::string name) {
52 std::list<xmlpp::Node*> n = xml_nodes (name);
54 throw XMLError ("duplicate XML tag");
55 } else if (n.empty ()) {
56 return boost::shared_ptr<T> ();
59 return boost::shared_ptr<T> (new T (n.front ()));
63 std::list<boost::shared_ptr<T> > sub_nodes (std::string name) {
64 std::list<xmlpp::Node*> n = xml_nodes (name);
65 std::list<boost::shared_ptr<T> > r;
66 for (typename std::list<xmlpp::Node*>::iterator i = n.begin(); i != n.end(); ++i) {
67 r.push_back (boost::shared_ptr<T> (new T (*i)));
73 std::list<boost::shared_ptr<T> > sub_nodes (std::string name, std::string sub) {
74 XMLNode p (xml_node (name));
75 return p.sub_nodes<T> (sub);
78 xmlpp::Node const * _node;
81 xmlpp::Node* xml_node (std::string);
82 std::list<xmlpp::Node*> xml_nodes (std::string);
83 std::list<Glib::ustring> _taken;
86 class XMLFile : public XMLNode
89 XMLFile (std::string file, std::string root_name);
93 xmlpp::DomParser* _parser;