Normalise XML attribute names to be camelCase (#2241).
[dcpomatic.git] / src / lib / util.h
index c62b98df65c140cfcedc90d13cbfca36e45dd181..7e7a7b96bcadded154f19d924cfdcd3667e096a7 100644 (file)
@@ -32,6 +32,7 @@
 #include "dcpomatic_time.h"
 #include "pixel_quanta.h"
 #include "types.h"
+#include <libcxml/cxml.h>
 #include <dcp/atmos_asset.h>
 #include <dcp/decrypted_kdm.h>
 #include <dcp/util.h>
@@ -150,4 +151,15 @@ list_to_vector (std::list<T> v)
        return l;
 }
 
+template <class T>
+T
+number_attribute(cxml::ConstNodePtr node, std::string name1, std::string name2)
+{
+       auto value = node->optional_number_attribute<T>(name1);
+       if (!value) {
+               value = node->number_attribute<T>(name2);
+       }
+       return *value;
+}
+
 #endif