diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-12-19 22:47:37 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-09-03 10:43:43 +0200 |
| commit | a55f7fa11991d222251a2a50f9349d8dbeed5ed7 (patch) | |
| tree | bc004308c7a2d9d32987624bb10d9e8503e7d86e /src/lib/xml_util.h | |
| parent | 32f606385df561d018e206afe2be0014ac40a812 (diff) | |
Move number_attribute() to xml_util.h
Diffstat (limited to 'src/lib/xml_util.h')
| -rw-r--r-- | src/lib/xml_util.h | 35 |
1 files changed, 35 insertions, 0 deletions
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 <cth@carlh.net> + + 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 <http://www.gnu.org/licenses/>. + +*/ + + +#include <libcxml/cxml.h> + + +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; +} + |
