27 #include "exceptions.h"
28 #include <libcxml/cxml.h>
35 optional_type_child (cxml::Node
const & node, std::string name)
37 std::list<boost::shared_ptr<cxml::Node> > n = node.node_children (name);
39 throw XMLError (
"duplicate XML tag");
40 }
else if (n.empty ()) {
41 return boost::shared_ptr<T> ();
44 return boost::shared_ptr<T> (
new T (n.front ()));
48 boost::shared_ptr<T> type_child (boost::shared_ptr<const cxml::Node> node, std::string name) {
49 return boost::shared_ptr<T> (
new T (node->node_child (name)));
54 optional_type_child (boost::shared_ptr<const cxml::Node> node, std::string name)
56 return optional_type_child<T> (*node.get(), name);
60 std::list<boost::shared_ptr<T> >
61 type_children (cxml::Node
const & node, std::string name)
63 std::list<boost::shared_ptr<cxml::Node> > n = node.node_children (name);
64 std::list<boost::shared_ptr<T> > r;
65 for (
typename std::list<boost::shared_ptr<cxml::Node> >::iterator i = n.begin(); i != n.end(); ++i) {
66 r.push_back (boost::shared_ptr<T> (
new T (*i)));
72 std::list<boost::shared_ptr<T> >
73 type_children (boost::shared_ptr<const cxml::Node> node, std::string name)
75 return type_children<T> (*node.get(), name);
79 std::list<boost::shared_ptr<T> >
80 type_grand_children (cxml::Node
const & node, std::string name, std::string
sub)
82 boost::shared_ptr<const cxml::Node> p = node.node_child (name);
83 return type_children<T> (p, sub);
87 std::list<boost::shared_ptr<T> >
88 type_grand_children (boost::shared_ptr<const cxml::Node> node, std::string name, std::string sub)
90 return type_grand_children<T> (*node.get(), name, sub);