From 5ad493e6900f621284748fe50b3f60f67929ffc2 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 22 Jan 2019 00:40:16 +0000 Subject: Fully indent PKL/CPL. --- src/util.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/util.cc') diff --git a/src/util.cc b/src/util.cc index df79fb26..d5b6cb9f 100644 --- a/src/util.cc +++ b/src/util.cc @@ -55,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -348,3 +349,30 @@ dcp::openjpeg_version () { return opj_version (); } + +string +dcp::spaces (int n) +{ + string s = ""; + for (int i = 0; i < n; ++i) { + s += " "; + } + return s; +} + +void +dcp::indent (xmlpp::Element* element, int initial) +{ + xmlpp::Node* last = 0; + BOOST_FOREACH (xmlpp::Node * n, element->get_children()) { + xmlpp::Element* e = dynamic_cast(n); + if (e) { + element->add_child_text_before (e, "\n" + spaces(initial + 2)); + indent (e, initial + 2); + last = n; + } + } + if (last) { + element->add_child_text (last, "\n" + spaces(initial)); + } +} -- cgit v1.2.3