From a55f7fa11991d222251a2a50f9349d8dbeed5ed7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 19 Dec 2024 22:47:37 +0100 Subject: Move number_attribute() to xml_util.h --- src/lib/util.h | 13 ------------- src/lib/xml_util.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 13 deletions(-) create mode 100644 src/lib/xml_util.h diff --git a/src/lib/util.h b/src/lib/util.h index 846059e1a..a3a384847 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -32,7 +32,6 @@ #include "dcpomatic_time.h" #include "pixel_quanta.h" #include "types.h" -#include #include #include #include @@ -103,18 +102,6 @@ extern std::string rfc_2822_date(time_t time); bool paths_exist(std::vector const& paths); std::function force(AVPixelFormat format); - -template -T -number_attribute(cxml::ConstNodePtr node, std::string name1, std::string name2) -{ - auto value = node->optional_number_attribute(name1); - if (!value) { - value = node->number_attribute(name2); - } - return *value; -} - extern std::string screen_names_to_string(std::vector names); extern std::string report_problem(); diff --git a/src/lib/xml_util.h b/src/lib/xml_util.h new file mode 100644 index 000000000..2dbade015 --- /dev/null +++ b/src/lib/xml_util.h @@ -0,0 +1,35 @@ +/* + Copyright (C) 2024 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include + + +template +T +number_attribute(cxml::ConstNodePtr node, std::string name1, std::string name2) +{ + auto value = node->optional_number_attribute(name1); + if (!value) { + value = node->number_attribute(name2); + } + return *value; +} + -- cgit v1.2.3