summaryrefslogtreecommitdiff
path: root/src/util.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2019-01-22 00:40:16 +0000
committerCarl Hetherington <cth@carlh.net>2019-01-22 00:40:16 +0000
commit12ada21654d7f0f8963f171ca7ee527ccba4627f (patch)
treeced5d983da3d0f39e305521eb390949c696945c1 /src/util.cc
parent33c2c1ddee9638fc4e59dbfdbeee2fb540778819 (diff)
Fully indent PKL/CPL.sony-debug
Diffstat (limited to 'src/util.cc')
-rw-r--r--src/util.cc28
1 files changed, 28 insertions, 0 deletions
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 <openssl/sha.h>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/foreach.hpp>
#include <stdexcept>
#include <iostream>
#include <iomanip>
@@ -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<xmlpp::Element*>(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));
+ }
+}