summaryrefslogtreecommitdiff
path: root/src/xml.h
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-01-23 15:35:24 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-23 15:35:24 +0100
commit6c37cc1979b2a01205a888c4c98f3334685ee8dd (patch)
tree9de52a3053e57bdf79a7986319cb097b33e46b5c /src/xml.h
parentb75d977a38f039fd68ed5d4055ae70b4bf631603 (diff)
Tidying.
Diffstat (limited to 'src/xml.h')
-rw-r--r--src/xml.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/xml.h b/src/xml.h
index 154ec210..6fec7f1b 100644
--- a/src/xml.h
+++ b/src/xml.h
@@ -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