diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-01-23 15:35:24 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-23 15:35:24 +0100 |
| commit | 6c37cc1979b2a01205a888c4c98f3334685ee8dd (patch) | |
| tree | 9de52a3053e57bdf79a7986319cb097b33e46b5c /src/xml.h | |
| parent | b75d977a38f039fd68ed5d4055ae70b4bf631603 (diff) | |
Tidying.
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 |
