Rename write_to_cpl_base -> write_to_cpl_asset.
[libdcp.git] / src / pkl.cc
index 621cf465f3a3fe5004b7acc58a249711eae89dce..b2fe875be0e056b7cb833d7b03eb24558cf6866e 100644 (file)
 
 using std::string;
 using boost::shared_ptr;
+using boost::optional;
 using namespace dcp;
 
 static string const pkl_interop_ns = "http://www.digicine.com/PROTO-ASDCP-PKL-20040311#";
 static string const pkl_smpte_ns   = "http://www.smpte-ra.org/schemas/429-8/2007/PKL";
 
 PKL::PKL (boost::filesystem::path file)
+       : _file (file)
 {
        cxml::Document pkl ("PackingList");
        pkl.read_file (file);
@@ -108,14 +110,17 @@ 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);
        }
 
-       doc.write_to_file (file.string(), "UTF-8");
+       doc.write_to_file_formatted (file.string(), "UTF-8");
+       _file = file;
 }
 
-string
+optional<string>
 PKL::hash (string id) const
 {
        BOOST_FOREACH (shared_ptr<Asset> i, _asset_list) {
@@ -124,10 +129,10 @@ PKL::hash (string id) const
                }
        }
 
-       DCP_ASSERT (false);
+       return optional<string>();
 }
 
-string
+optional<string>
 PKL::type (string id) const
 {
        BOOST_FOREACH (shared_ptr<Asset> i, _asset_list) {
@@ -136,5 +141,5 @@ PKL::type (string id) const
                }
        }
 
-       DCP_ASSERT (false);
+       return optional<string>();
 }