diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-01-22 00:40:16 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-01-22 00:40:16 +0000 |
| commit | 12ada21654d7f0f8963f171ca7ee527ccba4627f (patch) | |
| tree | ced5d983da3d0f39e305521eb390949c696945c1 | |
| parent | 33c2c1ddee9638fc4e59dbfdbeee2fb540778819 (diff) | |
Fully indent PKL/CPL.sony-debug
| -rw-r--r-- | src/certificate_chain.cc | 27 | ||||
| -rw-r--r-- | src/cpl.cc | 2 | ||||
| -rw-r--r-- | src/pkl.cc | 2 | ||||
| -rw-r--r-- | src/util.cc | 28 | ||||
| -rw-r--r-- | src/util.h | 2 |
5 files changed, 34 insertions, 27 deletions
diff --git a/src/certificate_chain.cc b/src/certificate_chain.cc index ebc3cc7f..353444fa 100644 --- a/src/certificate_chain.cc +++ b/src/certificate_chain.cc @@ -552,33 +552,6 @@ CertificateChain::root_to_leaf () const throw CertificateChainError ("certificate chain is not consistent"); } -static string -spaces (int n) -{ - string s = ""; - for (int i = 0; i < n; ++i) { - s += " "; - } - return s; -} - -static void -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)); - } -} - /** Add a <Signer> and <ds:Signature> nodes to an XML node. * @param parent XML node to add to. * @param standard INTEROP or SMPTE. @@ -164,6 +164,8 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons i->write_to_cpl (reel_list, standard); } + indent (root, 0); + if (signer) { signer->sign (root, standard); } @@ -109,6 +109,8 @@ PKL::write (boost::filesystem::path file, shared_ptr<const CertificateChain> sig asset->add_child("Type")->add_child_text (i->type); } + indent (pkl, 0); + if (signer) { signer->sign (pkl, _standard); } 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)); + } +} @@ -73,6 +73,8 @@ extern std::string file_to_string (boost::filesystem::path, uintmax_t max_length extern std::string private_key_fingerprint (std::string key); extern xmlpp::Node* find_child (xmlpp::Node const * node, std::string name); extern std::string openjpeg_version(); +extern std::string spaces (int n); +extern void indent (xmlpp::Element* element, int initial); } |
