diff options
Diffstat (limited to 'src/xml.h')
| -rw-r--r-- | src/xml.h | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -31,15 +31,24 @@ files in the program, then also delete it here. */ + +/** @file src/xml.h + * @brief Helpers for XML reading with libcxml + */ + + #ifndef LIBDCP_XML_H #define LIBDCP_XML_H + #include "exceptions.h" #include <libcxml/cxml.h> + namespace dcp { + template <class T> std::shared_ptr<T> optional_type_child (cxml::Node const & node, std::string name) @@ -54,11 +63,13 @@ optional_type_child (cxml::Node const & node, std::string name) return std::make_shared<T>(n.front()); } + template <class T> std::shared_ptr<T> type_child (std::shared_ptr<const cxml::Node> node, std::string name) { return std::make_shared<T>(node->node_child(name)); } + template <class T> std::shared_ptr<T> optional_type_child (std::shared_ptr<const cxml::Node> node, std::string name) @@ -66,6 +77,7 @@ optional_type_child (std::shared_ptr<const cxml::Node> node, std::string name) return optional_type_child<T> (*node.get(), name); } + template <class T> std::vector<std::shared_ptr<T>> type_children (cxml::Node const & node, std::string name) @@ -77,6 +89,7 @@ type_children (cxml::Node const & node, std::string name) return r; } + template <class T> std::vector<std::shared_ptr<T>> type_children (std::shared_ptr<const cxml::Node> node, std::string name) @@ -84,6 +97,7 @@ type_children (std::shared_ptr<const cxml::Node> node, std::string name) return type_children<T> (*node.get(), name); } + template <class T> std::vector<std::shared_ptr<T>> type_grand_children (cxml::Node const & node, std::string name, std::string sub) @@ -91,6 +105,7 @@ type_grand_children (cxml::Node const & node, std::string name, std::string sub) return type_children<T> (node.node_child(name), sub); } + template <class T> std::vector<std::shared_ptr<T>> type_grand_children (std::shared_ptr<const cxml::Node> node, std::string name, std::string sub) @@ -100,4 +115,5 @@ type_grand_children (std::shared_ptr<const cxml::Node> node, std::string name, s } + #endif |
