Normalise XML attribute names to be camelCase (#2241).
[dcpomatic.git] / src / lib / util.h
index b92869b253a776167c72bbd1b20159a1a9015e4e..2d65b92142005541f9a1391385085a655a2887d9 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>
@@ -98,4 +99,16 @@ extern bool contains_assetmap(boost::filesystem::path dir);
 extern std::string word_wrap(std::string input, int columns);
 extern void capture_ffmpeg_logs();
 
+
+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