Replace xmlpp::Node::add_child with cxml::add_child.
authorCarl Hetherington <cth@carlh.net>
Thu, 8 Feb 2024 23:29:00 +0000 (00:29 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 20 Mar 2024 17:21:14 +0000 (18:21 +0100)
30 files changed:
cscript
src/asset_map.cc
src/certificate_chain.cc
src/cpl.cc
src/dcp.cc
src/encrypted_kdm.cc
src/interop_subtitle_asset.cc
src/pkl.cc
src/rating.cc
src/reel.cc
src/reel_asset.cc
src/reel_asset.h
src/reel_atmos_asset.cc
src/reel_atmos_asset.h
src/reel_file_asset.cc
src/reel_file_asset.h
src/reel_interop_closed_caption_asset.cc
src/reel_interop_closed_caption_asset.h
src/reel_markers_asset.cc
src/reel_markers_asset.h
src/reel_picture_asset.cc
src/reel_picture_asset.h
src/reel_smpte_closed_caption_asset.cc
src/reel_smpte_closed_caption_asset.h
src/reel_subtitle_asset.cc
src/reel_subtitle_asset.h
src/smpte_subtitle_asset.cc
src/subtitle_asset_internal.cc
src/types.cc
test/shared_subtitle_test.cc

diff --git a/cscript b/cscript
index 5cfa5834c5b0e86cca62c90fd0caa04723bb8172..413f62c229b2653d79ad2a0c1a655f40a1abf3c8 100644 (file)
--- a/cscript
+++ b/cscript
@@ -35,7 +35,11 @@ import os
 import shutil
 
 def dependencies(target, options):
-    return (('libcxml', 'v0.17.6'), ('openjpeg', 'ad8edaacd54a862940d0a77c41ecda5858b54d6e'), ('asdcplib', '8a4a2f25cac0c58aac1d4267facab20e5ec3b57f'))
+    return (
+        ('libcxml', 'v0.17.8', options),
+        ('openjpeg', 'ad8edaacd54a862940d0a77c41ecda5858b54d6e'),
+        ('asdcplib', '8a4a2f25cac0c58aac1d4267facab20e5ec3b57f')
+    )
 
 def build(target, options):
     cmd = './waf configure --disable-examples --disable-dumpimage --disable-benchmarks --prefix=%s' % target.directory
index 281f27c3a520006040809837fa5dd238b6ea7143..0ee4b48670ed4ee3e4cb36a3eabd3767ee4ec00b 100644 (file)
@@ -165,29 +165,29 @@ AssetMap::write_xml(boost::filesystem::path file) const
                DCP_ASSERT (false);
        }
 
-       root->add_child("Id")->add_child_text("urn:uuid:" + _id);
+       cxml::add_text_child(root, "Id", "urn:uuid:" + _id);
        if (_annotation_text) {
-               root->add_child("AnnotationText")->add_child_text(*_annotation_text);
+               cxml::add_text_child(root, "AnnotationText", *_annotation_text);
        }
 
        switch (_standard) {
        case Standard::INTEROP:
-               root->add_child("VolumeCount")->add_child_text("1");
-               root->add_child("IssueDate")->add_child_text(_issue_date);
-               root->add_child("Issuer")->add_child_text(_issuer);
-               root->add_child("Creator")->add_child_text(_creator);
+               cxml::add_text_child(root, "VolumeCount", "1");
+               cxml::add_text_child(root, "IssueDate", _issue_date);
+               cxml::add_text_child(root, "Issuer", _issuer);
+               cxml::add_text_child(root, "Creator", _creator);
                break;
        case Standard::SMPTE:
-               root->add_child("Creator")->add_child_text(_creator);
-               root->add_child("VolumeCount")->add_child_text("1");
-               root->add_child("IssueDate")->add_child_text(_issue_date);
-               root->add_child("Issuer")->add_child_text(_issuer);
+               cxml::add_text_child(root, "Creator", _creator);
+               cxml::add_text_child(root, "VolumeCount", "1");
+               cxml::add_text_child(root, "IssueDate", _issue_date);
+               cxml::add_text_child(root, "Issuer", _issuer);
                break;
        default:
                DCP_ASSERT (false);
        }
 
-       auto asset_list = root->add_child("AssetList");
+       auto asset_list = cxml::add_child(root, "AssetList");
        for (auto const& asset: _assets) {
                asset.write_xml(asset_list, file.parent_path());
        }
@@ -200,20 +200,20 @@ AssetMap::write_xml(boost::filesystem::path file) const
 void
 AssetMap::Asset::write_xml(xmlpp::Element* asset_list, boost::filesystem::path dcp_root_directory) const
 {
-       auto node = asset_list->add_child("Asset");
-       node->add_child("Id")->add_child_text("urn:uuid:" + _id);
+       auto node = cxml::add_child(asset_list, "Asset");
+       cxml::add_text_child(node, "Id", "urn:uuid:" + _id);
        if (_pkl) {
-               node->add_child("PackingList")->add_child_text("true");
+               cxml::add_text_child(node, "PackingList", "true");
        }
-       auto chunk_list = node->add_child("ChunkList");
-       auto chunk = chunk_list->add_child("Chunk");
+       auto chunk_list = cxml::add_child(node, "ChunkList");
+       auto chunk = cxml::add_child(chunk_list, "Chunk");
 
        auto relative_path = relative_to_root(filesystem::canonical(dcp_root_directory), filesystem::canonical(_path));
        DCP_ASSERT(relative_path);
 
-       chunk->add_child("Path")->add_child_text(relative_path->generic_string());
-       chunk->add_child("VolumeIndex")->add_child_text("1");
-       chunk->add_child("Offset")->add_child_text("0");
-       chunk->add_child("Length")->add_child_text(raw_convert<string>(filesystem::file_size(_path)));
+       cxml::add_text_child(chunk, "Path", relative_path->generic_string());
+       cxml::add_text_child(chunk, "VolumeIndex", "1");
+       cxml::add_text_child(chunk, "Offset", "0");
+       cxml::add_text_child(chunk, "Length", raw_convert<string>(filesystem::file_size(_path)));
 }
 
index c4e3a9b03fa5fc7a8ccebbd581ba77b1b8edb31e..2bbddc7f8f66c9207c88999149612e774b02dfa1 100644 (file)
@@ -606,47 +606,47 @@ CertificateChain::sign (xmlpp::Element* parent, Standard standard) const
        /* <Signer> */
 
        parent->add_child_text("  ");
-       auto signer = parent->add_child("Signer");
+       auto signer = cxml::add_child(parent, "Signer");
        signer->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "dsig");
-       auto data = signer->add_child("X509Data", "dsig");
-       auto serial_element = data->add_child("X509IssuerSerial", "dsig");
-       serial_element->add_child("X509IssuerName", "dsig")->add_child_text (leaf().issuer());
-       serial_element->add_child("X509SerialNumber", "dsig")->add_child_text (leaf().serial());
-       data->add_child("X509SubjectName", "dsig")->add_child_text (leaf().subject());
+       auto data = cxml::add_child(signer, "X509Data", string("dsig"));
+       auto serial_element = cxml::add_child(data, "X509IssuerSerial", string("dsig"));
+       cxml::add_child(serial_element, "X509IssuerName", string("dsig"))->add_child_text(leaf().issuer());
+       cxml::add_child(serial_element, "X509SerialNumber", string("dsig"))->add_child_text(leaf().serial());
+       cxml::add_child(data, "X509SubjectName", string("dsig"))->add_child_text(leaf().subject());
 
        indent (signer, 2);
 
        /* <Signature> */
 
        parent->add_child_text("\n  ");
-       auto signature = parent->add_child("Signature");
+       auto signature = cxml::add_child(parent, "Signature");
        signature->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "dsig");
        signature->set_namespace ("dsig");
        parent->add_child_text("\n");
 
-       auto signed_info = signature->add_child ("SignedInfo", "dsig");
-       signed_info->add_child("CanonicalizationMethod", "dsig")->set_attribute ("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
+       auto signed_info = cxml::add_child(signature, "SignedInfo", string("dsig"));
+       cxml::add_child(signed_info, "CanonicalizationMethod", string("dsig"))->set_attribute("Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315");
 
        if (standard == Standard::INTEROP) {
-               signed_info->add_child("SignatureMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#rsa-sha1");
+               cxml::add_child(signed_info, "SignatureMethod", string("dsig"))->set_attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#rsa-sha1");
        } else {
-               signed_info->add_child("SignatureMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
+               cxml::add_child(signed_info, "SignatureMethod", string("dsig"))->set_attribute("Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
        }
 
-       auto reference = signed_info->add_child("Reference", "dsig");
+       auto reference = cxml::add_child(signed_info, "Reference", string("dsig"));
        reference->set_attribute ("URI", "");
 
-       auto transforms = reference->add_child("Transforms", "dsig");
-       transforms->add_child("Transform", "dsig")->set_attribute (
+       auto transforms = cxml::add_child(reference, "Transforms", string("dsig"));
+       cxml::add_child(transforms, "Transform", string("dsig"))->set_attribute(
                "Algorithm", "http://www.w3.org/2000/09/xmldsig#enveloped-signature"
                );
 
-       reference->add_child("DigestMethod", "dsig")->set_attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#sha1");
+       cxml::add_child(reference, "DigestMethod", string("dsig"))->set_attribute("Algorithm", "http://www.w3.org/2000/09/xmldsig#sha1");
        /* This will be filled in by the signing later */
-       reference->add_child("DigestValue", "dsig");
+       cxml::add_child(reference, "DigestValue", string("dsig"));
 
-       signature->add_child("SignatureValue", "dsig");
-       signature->add_child("KeyInfo", "dsig");
+       cxml::add_child(signature, "SignatureValue", string("dsig"));
+       cxml::add_child(signature, "KeyInfo", string("dsig"));
        add_signature_value (signature, "dsig", true);
 }
 
@@ -655,19 +655,20 @@ void
 CertificateChain::add_signature_value (xmlpp::Element* parent, string ns, bool add_indentation) const
 {
        cxml::Node cp (parent);
-       auto key_info = cp.node_child("KeyInfo")->node();
+       auto key_info = dynamic_cast<xmlpp::Element*>(cp.node_child("KeyInfo")->node());
+       DCP_ASSERT(key_info);
 
        /* Add the certificate chain to the KeyInfo child node of parent */
        for (auto const& i: leaf_to_root()) {
-               auto data = key_info->add_child("X509Data", ns);
+               auto data = cxml::add_child(key_info, "X509Data", ns);
 
                {
-                       auto serial = data->add_child("X509IssuerSerial", ns);
-                       serial->add_child("X509IssuerName", ns)->add_child_text (i.issuer ());
-                       serial->add_child("X509SerialNumber", ns)->add_child_text (i.serial ());
+                       auto serial = cxml::add_child(data, "X509IssuerSerial", ns);
+                       cxml::add_child(serial, "X509IssuerName", ns)->add_child_text(i.issuer());
+                       cxml::add_child(serial, "X509SerialNumber", ns)->add_child_text(i.serial());
                }
 
-               data->add_child("X509Certificate", ns)->add_child_text (i.certificate());
+               cxml::add_child(data, "X509Certificate", ns)->add_child_text(i.certificate());
        }
 
        auto signature_context = xmlSecDSigCtxCreate (0);
index 5467fef3b1db0b38ebf859e5d4adf623e7342dd7..6a9a46b54d6d53673bfcfcc80fb466a151fce880 100644 (file)
@@ -194,15 +194,15 @@ CPL::write_xml(boost::filesystem::path file, shared_ptr<const CertificateChain>
                root = doc.create_root_node ("CompositionPlaylist", cpl_smpte_ns);
        }
 
-       root->add_child("Id")->add_child_text ("urn:uuid:" + _id);
+       cxml::add_text_child(root, "Id", "urn:uuid:" + _id);
        if (_annotation_text) {
-               root->add_child("AnnotationText")->add_child_text (*_annotation_text);
+               cxml::add_text_child(root, "AnnotationText", *_annotation_text);
        }
-       root->add_child("IssueDate")->add_child_text (_issue_date);
-       root->add_child("Issuer")->add_child_text (_issuer);
-       root->add_child("Creator")->add_child_text (_creator);
-       root->add_child("ContentTitleText")->add_child_text (_content_title_text);
-       auto content_kind = root->add_child("ContentKind");
+       cxml::add_text_child(root, "IssueDate", _issue_date);
+       cxml::add_text_child(root, "Issuer", _issuer);
+       cxml::add_text_child(root, "Creator", _creator);
+       cxml::add_text_child(root, "ContentTitleText", _content_title_text);
+       auto content_kind = cxml::add_child(root, "ContentKind");
        content_kind->add_child_text(_content_kind.name());
        if (_content_kind.scope()) {
                content_kind->set_attribute("scope", *_content_kind.scope());
@@ -214,12 +214,12 @@ CPL::write_xml(boost::filesystem::path file, shared_ptr<const CertificateChain>
                _content_versions[0].as_xml (root);
        }
 
-       auto rating_list = root->add_child("RatingList");
+       auto rating_list = cxml::add_child(root, "RatingList");
        for (auto i: _ratings) {
-               i.as_xml (rating_list->add_child("Rating"));
+               i.as_xml(cxml::add_child(rating_list, "Rating"));
        }
 
-       auto reel_list = root->add_child ("ReelList");
+       auto reel_list = cxml::add_child(root, "ReelList");
 
        if (_reels.empty()) {
                throw NoReelsError ();
@@ -373,27 +373,27 @@ CPL::write_mca_subdescriptors(xmlpp::Element* parent, shared_ptr<const SoundAsse
                reinterpret_cast<ASDCP::MXF::InterchangeObject**>(&soundfield)
                );
        if (KM_SUCCESS(r)) {
-               auto mca_subs = parent->add_child("mca:MCASubDescriptors");
+               auto mca_subs = cxml::add_child(parent, "mca:MCASubDescriptors");
                mca_subs->set_namespace_declaration (mca_sub_descriptors_ns, "mca");
                mca_subs->set_namespace_declaration (smpte_395_ns, "r0");
                mca_subs->set_namespace_declaration (smpte_335_ns, "r1");
-               auto sf = mca_subs->add_child("SoundfieldGroupLabelSubDescriptor", "r0");
+               auto sf = cxml::add_child(mca_subs, "SoundfieldGroupLabelSubDescriptor", string("r0"));
                char buffer[64];
                soundfield->InstanceUID.EncodeString(buffer, sizeof(buffer));
-               sf->add_child("InstanceID", "r1")->add_child_text("urn:uuid:" + string(buffer));
+               cxml::add_child(sf, "InstanceID", string("r1"))->add_child_text("urn:uuid:" + string(buffer));
                soundfield->MCALabelDictionaryID.EncodeString(buffer, sizeof(buffer));
-               sf->add_child("MCALabelDictionaryID", "r1")->add_child_text("urn:smpte:ul:" + string(buffer));
+               cxml::add_child(sf, "MCALabelDictionaryID", string("r1"))->add_child_text("urn:smpte:ul:" + string(buffer));
                soundfield->MCALinkID.EncodeString(buffer, sizeof(buffer));
-               sf->add_child("MCALinkID", "r1")->add_child_text("urn:uuid:" + string(buffer));
+               cxml::add_child(sf, "MCALinkID", string("r1"))->add_child_text("urn:uuid:" + string(buffer));
                soundfield->MCATagSymbol.EncodeString(buffer, sizeof(buffer));
-               sf->add_child("MCATagSymbol", "r1")->add_child_text(buffer);
+               cxml::add_child(sf, "MCATagSymbol", string("r1"))->add_child_text(buffer);
                if (!soundfield->MCATagName.empty()) {
                        soundfield->MCATagName.get().EncodeString(buffer, sizeof(buffer));
-                       sf->add_child("MCATagName", "r1")->add_child_text(buffer);
+                       cxml::add_child(sf, "MCATagName", string("r1"))->add_child_text(buffer);
                }
                if (!soundfield->RFC5646SpokenLanguage.empty()) {
                        soundfield->RFC5646SpokenLanguage.get().EncodeString(buffer, sizeof(buffer));
-                       sf->add_child("RFC5646SpokenLanguage", "r1")->add_child_text(buffer);
+                       cxml::add_child(sf, "RFC5646SpokenLanguage", string("r1"))->add_child_text(buffer);
                }
 
                /* Find the MCA subdescriptors in the MXF so that we can also write them here */
@@ -405,29 +405,29 @@ CPL::write_mca_subdescriptors(xmlpp::Element* parent, shared_ptr<const SoundAsse
 
                for (auto i: channels) {
                        auto channel = reinterpret_cast<ASDCP::MXF::AudioChannelLabelSubDescriptor*>(i);
-                       auto ch = mca_subs->add_child("AudioChannelLabelSubDescriptor", "r0");
+                       auto ch = cxml::add_child(mca_subs, "AudioChannelLabelSubDescriptor", string("r0"));
                        channel->InstanceUID.EncodeString(buffer, sizeof(buffer));
-                       ch->add_child("InstanceID", "r1")->add_child_text("urn:uuid:" + string(buffer));
+                       cxml::add_child(ch, "InstanceID", string("r1"))->add_child_text("urn:uuid:" + string(buffer));
                        channel->MCALabelDictionaryID.EncodeString(buffer, sizeof(buffer));
-                       ch->add_child("MCALabelDictionaryID", "r1")->add_child_text("urn:smpte:ul:" + string(buffer));
+                       cxml::add_child(ch, "MCALabelDictionaryID", string("r1"))->add_child_text("urn:smpte:ul:" + string(buffer));
                        channel->MCALinkID.EncodeString(buffer, sizeof(buffer));
-                       ch->add_child("MCALinkID", "r1")->add_child_text("urn:uuid:" + string(buffer));
+                       cxml::add_child(ch, "MCALinkID", string("r1"))->add_child_text("urn:uuid:" + string(buffer));
                        channel->MCATagSymbol.EncodeString(buffer, sizeof(buffer));
-                       ch->add_child("MCATagSymbol", "r1")->add_child_text(buffer);
+                       cxml::add_child(ch, "MCATagSymbol", string("r1"))->add_child_text(buffer);
                        if (!channel->MCATagName.empty()) {
                                channel->MCATagName.get().EncodeString(buffer, sizeof(buffer));
-                               ch->add_child("MCATagName", "r1")->add_child_text(buffer);
+                               cxml::add_child(ch, "MCATagName", string("r1"))->add_child_text(buffer);
                        }
                        if (!channel->MCAChannelID.empty()) {
-                               ch->add_child("MCAChannelID", "r1")->add_child_text(raw_convert<string>(channel->MCAChannelID.get()));
+                               cxml::add_child(ch, "MCAChannelID", string("r1"))->add_child_text(raw_convert<string>(channel->MCAChannelID.get()));
                        }
                        if (!channel->RFC5646SpokenLanguage.empty()) {
                                channel->RFC5646SpokenLanguage.get().EncodeString(buffer, sizeof(buffer));
-                               ch->add_child("RFC5646SpokenLanguage", "r1")->add_child_text(buffer);
+                               cxml::add_child(ch, "RFC5646SpokenLanguage", string("r1"))->add_child_text(buffer);
                        }
                        if (!channel->SoundfieldGroupLinkID.empty()) {
                                channel->SoundfieldGroupLinkID.get().EncodeString(buffer, sizeof(buffer));
-                               ch->add_child("SoundfieldGroupLinkID", "r1")->add_child_text("urn:uuid:" + string(buffer));
+                               cxml::add_child(ch, "SoundfieldGroupLinkID", string("r1"))->add_child_text("urn:uuid:" + string(buffer));
                        }
                }
        }
@@ -451,16 +451,16 @@ CPL::maybe_write_composition_metadata_asset(xmlpp::Element* node, bool include_m
                return;
        }
 
-       auto meta = node->add_child("meta:CompositionMetadataAsset");
+       auto meta = cxml::add_child(node, "meta:CompositionMetadataAsset");
        meta->set_namespace_declaration (cpl_metadata_ns, "meta");
 
-       meta->add_child("Id")->add_child_text("urn:uuid:" + _cpl_metadata_id);
+       cxml::add_text_child(meta, "Id", "urn:uuid:" + _cpl_metadata_id);
 
        auto mp = _reels.front()->main_picture();
-       meta->add_child("EditRate")->add_child_text(mp->edit_rate().as_string());
-       meta->add_child("IntrinsicDuration")->add_child_text(raw_convert<string>(mp->intrinsic_duration()));
+       cxml::add_text_child(meta, "EditRate", mp->edit_rate().as_string());
+       cxml::add_text_child(meta, "IntrinsicDuration", raw_convert<string>(mp->intrinsic_duration()));
 
-       auto fctt = meta->add_child("FullContentTitleText", "meta");
+       auto fctt = cxml::add_child(meta, "FullContentTitleText", string("meta"));
        if (_full_content_title_text && !_full_content_title_text->empty()) {
                fctt->add_child_text (*_full_content_title_text);
        }
@@ -469,11 +469,11 @@ CPL::maybe_write_composition_metadata_asset(xmlpp::Element* node, bool include_m
        }
 
        if (_release_territory) {
-               meta->add_child("ReleaseTerritory", "meta")->add_child_text(*_release_territory);
+               cxml::add_child(meta, "ReleaseTerritory", string("meta"))->add_child_text(*_release_territory);
        }
 
        if (_version_number) {
-               xmlpp::Element* vn = meta->add_child("VersionNumber", "meta");
+               auto vn = cxml::add_child(meta, "VersionNumber", string("meta"));
                vn->add_child_text(raw_convert<string>(*_version_number));
                if (_status) {
                        vn->set_attribute("status", status_to_string(*_status));
@@ -481,19 +481,19 @@ CPL::maybe_write_composition_metadata_asset(xmlpp::Element* node, bool include_m
        }
 
        if (_chain) {
-               meta->add_child("Chain", "meta")->add_child_text(*_chain);
+               cxml::add_child(meta, "Chain", string("meta"))->add_child_text(*_chain);
        }
 
        if (_distributor) {
-               meta->add_child("Distributor", "meta")->add_child_text(*_distributor);
+               cxml::add_child(meta, "Distributor", string("meta"))->add_child_text(*_distributor);
        }
 
        if (_facility) {
-               meta->add_child("Facility", "meta")->add_child_text(*_facility);
+               cxml::add_child(meta, "Facility", string("meta"))->add_child_text(*_facility);
        }
 
        if (_content_versions.size() > 1) {
-               xmlpp::Element* vc = meta->add_child("AlternateContentVersionList", "meta");
+               auto vc = cxml::add_child(meta, "AlternateContentVersionList", string("meta"));
                for (size_t i = 1; i < _content_versions.size(); ++i) {
                        _content_versions[i].as_xml (vc);
                }
@@ -504,17 +504,17 @@ CPL::maybe_write_composition_metadata_asset(xmlpp::Element* node, bool include_m
        }
 
        if (_main_sound_configuration) {
-               meta->add_child("MainSoundConfiguration", "meta")->add_child_text(_main_sound_configuration->to_string());
+               cxml::add_child(meta, "MainSoundConfiguration", string("meta"))->add_child_text(_main_sound_configuration->to_string());
        }
-       meta->add_child("MainSoundSampleRate", "meta")->add_child_text(raw_convert<string>(*_main_sound_sample_rate) + " 1");
+       cxml::add_child(meta, "MainSoundSampleRate", string("meta"))->add_child_text(raw_convert<string>(*_main_sound_sample_rate) + " 1");
 
-       auto stored = meta->add_child("MainPictureStoredArea", "meta");
-       stored->add_child("Width", "meta")->add_child_text(raw_convert<string>(_main_picture_stored_area->width));
-       stored->add_child("Height", "meta")->add_child_text(raw_convert<string>(_main_picture_stored_area->height));
+       auto stored = cxml::add_child(meta, "MainPictureStoredArea", string("meta"));
+       cxml::add_child(stored, "Width", string("meta"))->add_child_text(raw_convert<string>(_main_picture_stored_area->width));
+       cxml::add_child(stored, "Height", string("meta"))->add_child_text(raw_convert<string>(_main_picture_stored_area->height));
 
-       auto active = meta->add_child("MainPictureActiveArea", "meta");
-       active->add_child("Width", "meta")->add_child_text(raw_convert<string>(_main_picture_active_area->width));
-       active->add_child("Height", "meta")->add_child_text(raw_convert<string>(_main_picture_active_area->height));
+       auto active = cxml::add_child(meta, "MainPictureActiveArea", string("meta"));
+       cxml::add_child(active, "Width", string("meta"))->add_child_text(raw_convert<string>(_main_picture_active_area->width));
+       cxml::add_child(active, "Height", string("meta"))->add_child_text(raw_convert<string>(_main_picture_active_area->height));
 
        optional<string> first_subtitle_language;
        for (auto i: _reels) {
@@ -537,18 +537,18 @@ CPL::maybe_write_composition_metadata_asset(xmlpp::Element* node, bool include_m
                        }
                        lang += i;
                }
-               meta->add_child("MainSubtitleLanguageList", "meta")->add_child_text(lang);
+               cxml::add_child(meta, "MainSubtitleLanguageList", string("meta"))->add_child_text(lang);
        }
 
-       auto metadata_list = meta->add_child("ExtensionMetadataList", "meta");
+       auto metadata_list = cxml::add_child(meta, "ExtensionMetadataList", string("meta"));
 
        auto add_extension_metadata = [metadata_list](string scope, string name, string property_name, string property_value) {
-               auto extension = metadata_list->add_child("ExtensionMetadata", "meta");
+               auto extension = cxml::add_child(metadata_list, "ExtensionMetadata", string("meta"));
                extension->set_attribute("scope", scope);
-               extension->add_child("Name", "meta")->add_child_text(name);
-               auto property = extension->add_child("PropertyList", "meta")->add_child("Property", "meta");
-               property->add_child("Name", "meta")->add_child_text(property_name);
-               property->add_child("Value", "meta")->add_child_text(property_value);
+               cxml::add_child(extension, "Name", string("meta"))->add_child_text(name);
+               auto property = cxml::add_child(cxml::add_child(extension, "PropertyList", string("meta")), "Property", string("meta"));
+               cxml::add_child(property, "Name", string("meta"))->add_child_text(property_name);
+               cxml::add_child(property, "Value", string("meta"))->add_child_text(property_value);
        };
 
        /* SMPTE Bv2.1 8.6.3 */
index d603cfae48694ae71d89ae9f0b57a673efd0381a..2906d575a73b1a167037184cae76b09c3a2a5b82 100644 (file)
@@ -441,7 +441,7 @@ DCP::write_volindex (Standard standard) const
                DCP_ASSERT (false);
        }
 
-       root->add_child("Index")->add_child_text ("1");
+       cxml::add_text_child(root, "Index", "1");
        doc.write_to_file_formatted(dcp::filesystem::fix_long_path(p).string(), "UTF-8");
 }
 
index 465a657da2a60512791a91fff4e9bb571501e7e7..5b33e3f6b91fe66883392a05525a2b5d637eb2e7 100644 (file)
@@ -85,8 +85,8 @@ public:
 
        void as_xml (xmlpp::Element* node) const
        {
-               node->add_child("X509IssuerName", "ds")->add_child_text (x509_issuer_name);
-               node->add_child("X509SerialNumber", "ds")->add_child_text (x509_serial_number);
+               cxml::add_child(node, "X509IssuerName", string("ds"))->add_child_text(x509_issuer_name);
+               cxml::add_child(node, "X509SerialNumber", string("ds"))->add_child_text(x509_serial_number);
        }
 
        string x509_issuer_name;
@@ -108,8 +108,8 @@ public:
 
        void as_xml (xmlpp::Element* node) const
        {
-               x509_issuer_serial.as_xml (node->add_child ("X509IssuerSerial", "ds"));
-               node->add_child("X509Certificate", "ds")->add_child_text (x509_certificate);
+               x509_issuer_serial.as_xml(cxml::add_child(node, "X509IssuerSerial", string("ds")));
+               cxml::add_child(node, "X509Certificate", string("ds"))->add_child_text(x509_certificate);
        }
 
        Signer x509_issuer_serial;
@@ -136,8 +136,8 @@ public:
        void as_xml (xmlpp::Element* node) const
        {
                node->set_attribute ("URI", uri);
-               node->add_child("DigestMethod", "ds")->set_attribute ("Algorithm", "http://www.w3.org/2001/04/xmlenc#sha256");
-               node->add_child("DigestValue", "ds")->add_child_text (digest_value);
+               cxml::add_child(node, "DigestMethod", string("ds"))->set_attribute("Algorithm", "http://www.w3.org/2001/04/xmlenc#sha256");
+               cxml::add_child(node, "DigestValue", string("ds"))->add_child_text(digest_value);
        }
 
        string uri;
@@ -168,16 +168,16 @@ public:
 
        void as_xml (xmlpp::Element* node) const
        {
-               node->add_child ("CanonicalizationMethod", "ds")->set_attribute (
+               cxml::add_child(node, "CanonicalizationMethod", string("ds"))->set_attribute(
                        "Algorithm", "http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"
                        );
 
-               node->add_child ("SignatureMethod", "ds")->set_attribute (
+               cxml::add_child(node, "SignatureMethod", string("ds"))->set_attribute(
                        "Algorithm", "http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"
                        );
 
-               authenticated_public.as_xml (node->add_child ("Reference", "ds"));
-               authenticated_private.as_xml (node->add_child ("Reference", "ds"));
+               authenticated_public.as_xml(cxml::add_child(node, "Reference", string("ds")));
+               authenticated_private.as_xml(cxml::add_child(node, "Reference", string("ds")));
        }
 
 private:
@@ -200,14 +200,14 @@ public:
                }
        }
 
-       void as_xml (xmlpp::Node* node) const
+       void as_xml(xmlpp::Element* element) const
        {
-               signed_info.as_xml (node->add_child ("SignedInfo", "ds"));
-               node->add_child("SignatureValue", "ds")->add_child_text (signature_value);
+               signed_info.as_xml(cxml::add_child(element, "SignedInfo", string("ds")));
+               cxml::add_child(element, "SignatureValue", string("ds"))->add_child_text(signature_value);
 
-               auto key_info_node = node->add_child("KeyInfo", "ds");
+               auto key_info_node = cxml::add_child(element, "KeyInfo", string("ds"));
                for (auto i: x509_data) {
-                       i.as_xml (key_info_node->add_child("X509Data", "ds"));
+                       i.as_xml(cxml::add_child(key_info_node, "X509Data", string("ds")));
                }
        }
 
@@ -234,17 +234,17 @@ public:
                references["ID_AuthenticatedPrivate"] = node->set_attribute ("Id", "ID_AuthenticatedPrivate");
 
                for (auto i: encrypted_key) {
-                       auto encrypted_key = node->add_child ("EncryptedKey", "enc");
+                       auto encrypted_key = cxml::add_child(node, "EncryptedKey", string("enc"));
                        /* XXX: hack for testing with Dolby */
                        encrypted_key->set_namespace_declaration ("http://www.w3.org/2001/04/xmlenc#", "enc");
-                       auto encryption_method = encrypted_key->add_child("EncryptionMethod", "enc");
+                       auto encryption_method = cxml::add_child(encrypted_key, "EncryptionMethod", string("enc"));
                        encryption_method->set_attribute ("Algorithm", "http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p");
-                       auto digest_method = encryption_method->add_child ("DigestMethod", "ds");
+                       auto digest_method = cxml::add_child(encryption_method, "DigestMethod", string("ds"));
                        /* XXX: hack for testing with Dolby */
                        digest_method->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "ds");
                        digest_method->set_attribute ("Algorithm", "http://www.w3.org/2000/09/xmldsig#sha1");
-                       auto cipher_data = encrypted_key->add_child("CipherData", "enc");
-                       cipher_data->add_child("CipherValue", "enc")->add_child_text (i);
+                       auto cipher_data = cxml::add_child(encrypted_key, "CipherData", string("enc"));
+                       cxml::add_child(cipher_data, "CipherValue", string("enc"))->add_child_text(i);
                }
        }
 
@@ -271,9 +271,9 @@ public:
 
        void as_xml (xmlpp::Element* node) const
        {
-               auto type = node->add_child("KeyType");
+               auto type = cxml::add_child(node, "KeyType");
                type->add_child_text (key_type);
-               node->add_child("KeyId")->add_child_text ("urn:uuid:" + key_id);
+               cxml::add_text_child(node, "KeyId", "urn:uuid:" + key_id);
                /* XXX: this feels like a bit of a hack */
                if (key_type == "MDEK") {
                        type->set_attribute ("scope", "http://www.dolby.com/cp850/2012/KDM#kdm-key-type");
@@ -302,7 +302,7 @@ public:
        void as_xml (xmlpp::Element* node) const
        {
                for (auto const& i: typed_key_id) {
-                       i.as_xml (node->add_child("TypedKeyId"));
+                       i.as_xml(cxml::add_child(node, ("TypedKeyId")));
                }
        }
 
@@ -326,13 +326,13 @@ public:
 
        void as_xml (xmlpp::Element* node) const
        {
-               node->add_child ("DeviceListIdentifier")->add_child_text ("urn:uuid:" + device_list_identifier);
+               cxml::add_text_child(node, "DeviceListIdentifier", "urn:uuid:" + device_list_identifier);
                if (device_list_description) {
-                       node->add_child ("DeviceListDescription")->add_child_text (device_list_description.get());
+                       cxml::add_text_child(node, "DeviceListDescription", device_list_description.get());
                }
-               auto device_list = node->add_child ("DeviceList");
+               auto device_list = cxml::add_child(node, "DeviceList");
                for (auto i: certificate_thumbprints) {
-                       device_list->add_child("CertificateThumbprint")->add_child_text (i);
+                       cxml::add_text_child(device_list, "CertificateThumbprint", i);
                }
        }
 
@@ -357,8 +357,8 @@ public:
 
        void as_xml (xmlpp::Element* node) const
        {
-               node->add_child("X509IssuerName", "ds")->add_child_text (x509_issuer_name);
-               node->add_child("X509SerialNumber", "ds")->add_child_text (x509_serial_number);
+               cxml::add_child(node, "X509IssuerName", string("ds"))->add_child_text(x509_issuer_name);
+               cxml::add_child(node, "X509SerialNumber", string("ds"))->add_child_text(x509_serial_number);
        }
 
        string x509_issuer_name;
@@ -380,8 +380,8 @@ public:
 
        void as_xml (xmlpp::Element* node) const
        {
-               x509_issuer_serial.as_xml (node->add_child ("X509IssuerSerial"));
-               node->add_child("X509SubjectName")->add_child_text (x509_subject_name);
+               x509_issuer_serial.as_xml(cxml::add_child(node, "X509IssuerSerial"));
+               cxml::add_text_child(node, "X509SubjectName", x509_subject_name);
        }
 
        X509IssuerSerial x509_issuer_serial;
@@ -428,30 +428,30 @@ public:
        {
                node->set_attribute ("xmlns", "http://www.smpte-ra.org/schemas/430-1/2006/KDM");
 
-               recipient.as_xml (node->add_child ("Recipient"));
-               node->add_child("CompositionPlaylistId")->add_child_text ("urn:uuid:" + composition_playlist_id);
-               node->add_child("ContentTitleText")->add_child_text (content_title_text);
+               recipient.as_xml(cxml::add_child(node, "Recipient"));
+               cxml::add_text_child(node, "CompositionPlaylistId", "urn:uuid:" + composition_playlist_id);
+               cxml::add_text_child(node, "ContentTitleText", content_title_text);
                if (content_authenticator) {
-                       node->add_child("ContentAuthenticator")->add_child_text (content_authenticator.get ());
+                       cxml::add_text_child(node, "ContentAuthenticator", content_authenticator.get());
                }
-               node->add_child("ContentKeysNotValidBefore")->add_child_text (not_valid_before.as_string ());
-               node->add_child("ContentKeysNotValidAfter")->add_child_text (not_valid_after.as_string ());
+               cxml::add_text_child(node, "ContentKeysNotValidBefore", not_valid_before.as_string());
+               cxml::add_text_child(node, "ContentKeysNotValidAfter", not_valid_after.as_string());
                if (authorized_device_info) {
-                       authorized_device_info->as_xml (node->add_child ("AuthorizedDeviceInfo"));
+                       authorized_device_info->as_xml(cxml::add_child(node, "AuthorizedDeviceInfo"));
                }
-               key_id_list.as_xml (node->add_child ("KeyIdList"));
+               key_id_list.as_xml(cxml::add_child(node, "KeyIdList"));
 
                if (disable_forensic_marking_picture || disable_forensic_marking_audio) {
-                       auto forensic_mark_flag_list = node->add_child ("ForensicMarkFlagList");
+                       auto forensic_mark_flag_list = cxml::add_child(node, "ForensicMarkFlagList");
                        if (disable_forensic_marking_picture) {
-                               forensic_mark_flag_list->add_child("ForensicMarkFlag")->add_child_text(picture_disable);
+                               cxml::add_text_child(forensic_mark_flag_list, "ForensicMarkFlag", picture_disable);
                        }
                        if (disable_forensic_marking_audio) {
                                auto mrkflg = audio_disable;
                                if (*disable_forensic_marking_audio > 0) {
                                        mrkflg += String::compose ("-above-channel-%1", *disable_forensic_marking_audio);
                                }
-                               forensic_mark_flag_list->add_child("ForensicMarkFlag")->add_child_text (mrkflg);
+                               cxml::add_text_child(forensic_mark_flag_list, "ForensicMarkFlag", mrkflg);
                        }
                }
        }
@@ -490,7 +490,7 @@ public:
 
        void as_xml (xmlpp::Element* node) const
        {
-               kdm_required_extensions.as_xml (node->add_child ("KDMRequiredExtensions"));
+               kdm_required_extensions.as_xml(cxml::add_child(node, "KDMRequiredExtensions"));
        }
 
        KDMRequiredExtensions kdm_required_extensions;
@@ -521,17 +521,17 @@ public:
        {
                references["ID_AuthenticatedPublic"] = node->set_attribute ("Id", "ID_AuthenticatedPublic");
 
-               node->add_child("MessageId")->add_child_text ("urn:uuid:" + message_id);
-               node->add_child("MessageType")->add_child_text ("http://www.smpte-ra.org/430-1/2006/KDM#kdm-key-type");
+               cxml::add_text_child(node, "MessageId", "urn:uuid:" + message_id);
+               cxml::add_text_child(node, "MessageType", "http://www.smpte-ra.org/430-1/2006/KDM#kdm-key-type");
                if (annotation_text) {
-                       node->add_child("AnnotationText")->add_child_text (annotation_text.get ());
+                       cxml::add_text_child(node, "AnnotationText", annotation_text.get());
                }
-               node->add_child("IssueDate")->add_child_text (issue_date);
+               cxml::add_text_child(node, "IssueDate", issue_date);
 
-               signer.as_xml (node->add_child ("Signer"));
-               required_extensions.as_xml (node->add_child ("RequiredExtensions"));
+               signer.as_xml(cxml::add_child(node, "Signer"));
+               required_extensions.as_xml(cxml::add_child(node, "RequiredExtensions"));
 
-               node->add_child ("NonCriticalExtensions");
+               cxml::add_child(node, "NonCriticalExtensions");
        }
 
        string message_id;
@@ -563,14 +563,14 @@ public:
 
        shared_ptr<xmlpp::Document> as_xml () const
        {
-               shared_ptr<xmlpp::Document> document (new xmlpp::Document ());
-               xmlpp::Element* root = document->create_root_node ("DCinemaSecurityMessage", "http://www.smpte-ra.org/schemas/430-3/2006/ETM");
+               auto document = make_shared<xmlpp::Document>();
+               auto root = document->create_root_node("DCinemaSecurityMessage", "http://www.smpte-ra.org/schemas/430-3/2006/ETM");
                root->set_namespace_declaration ("http://www.w3.org/2000/09/xmldsig#", "ds");
                root->set_namespace_declaration ("http://www.w3.org/2001/04/xmlenc#", "enc");
                map<string, xmlpp::Attribute *> references;
-               authenticated_public.as_xml (root->add_child ("AuthenticatedPublic"), references);
-               authenticated_private.as_xml (root->add_child ("AuthenticatedPrivate"), references);
-               signature.as_xml (root->add_child ("Signature", "ds"));
+               authenticated_public.as_xml(cxml::add_child(root, "AuthenticatedPublic"), references);
+               authenticated_private.as_xml(cxml::add_child(root, "AuthenticatedPrivate"), references);
+               signature.as_xml(cxml::add_child(root, "Signature", string("ds")));
 
                for (auto i: references) {
                        xmlAddID (0, document->cobj(), (const xmlChar *) i.first.c_str(), i.second->cobj());
index 32c3f66a4268649985fb0c031313b54c5b9123cc..a45942077f1f87da33a9b101f0eae39fdd71b6c8 100644 (file)
@@ -115,13 +115,13 @@ InteropSubtitleAsset::xml_as_string () const
        auto root = doc.create_root_node ("DCSubtitle");
        root->set_attribute ("Version", "1.0");
 
-       root->add_child("SubtitleID")->add_child_text (_id);
-       root->add_child("MovieTitle")->add_child_text (_movie_title);
-       root->add_child("ReelNumber")->add_child_text (raw_convert<string> (_reel_number));
-       root->add_child("Language")->add_child_text (_language);
+       cxml::add_text_child(root, "SubtitleID", _id);
+       cxml::add_text_child(root, "MovieTitle", _movie_title);
+       cxml::add_text_child(root, "ReelNumber", raw_convert<string> (_reel_number));
+       cxml::add_text_child(root, "Language", _language);
 
        for (auto i: _load_font_nodes) {
-               auto load_font = root->add_child("LoadFont");
+               auto load_font = cxml::add_child(root, "LoadFont");
                load_font->set_attribute ("Id", i->id);
                load_font->set_attribute ("URI", i->uri);
        }
index 57eda9dad025dd285ed725f2b8614b570417845e..463d046acaac5d54968a4cbde6b2974b88235049 100644 (file)
@@ -105,26 +105,26 @@ PKL::write_xml (boost::filesystem::path file, shared_ptr<const CertificateChain>
                pkl = doc.create_root_node("PackingList", pkl_smpte_ns);
        }
 
-       pkl->add_child("Id")->add_child_text ("urn:uuid:" + _id);
+       cxml::add_text_child(pkl, "Id", "urn:uuid:" + _id);
        if (_annotation_text) {
-               pkl->add_child("AnnotationText")->add_child_text (*_annotation_text);
+               cxml::add_text_child(pkl, "AnnotationText", *_annotation_text);
        }
-       pkl->add_child("IssueDate")->add_child_text (_issue_date);
-       pkl->add_child("Issuer")->add_child_text (_issuer);
-       pkl->add_child("Creator")->add_child_text (_creator);
+       cxml::add_text_child(pkl, "IssueDate", _issue_date);
+       cxml::add_text_child(pkl, "Issuer", _issuer);
+       cxml::add_text_child(pkl, "Creator", _creator);
 
-       auto asset_list = pkl->add_child("AssetList");
+       auto asset_list = cxml::add_child(pkl, "AssetList");
        for (auto i: _assets) {
-               auto asset = asset_list->add_child("Asset");
-               asset->add_child("Id")->add_child_text ("urn:uuid:" + i->id());
+               auto asset = cxml::add_child(asset_list, "Asset");
+               cxml::add_text_child(asset, "Id", "urn:uuid:" + i->id());
                if (i->annotation_text()) {
-                       asset->add_child("AnnotationText")->add_child_text (*i->annotation_text());
+                       cxml::add_text_child(asset, "AnnotationText", *i->annotation_text());
                }
-               asset->add_child("Hash")->add_child_text (i->hash());
-               asset->add_child("Size")->add_child_text (raw_convert<string>(i->size()));
-               asset->add_child("Type")->add_child_text (i->type());
+               cxml::add_text_child(asset, "Hash", i->hash());
+               cxml::add_text_child(asset, "Size", raw_convert<string>(i->size()));
+               cxml::add_text_child(asset, "Type", i->type());
                if (auto filename = i->original_filename()) {
-                       asset->add_child("OriginalFileName")->add_child_text(*filename);
+                       cxml::add_text_child(asset, "OriginalFileName", *filename);
                }
        }
 
index 21960365f0c6637a0c2794fa7f9cd3d638705c35..156d5ad02fd811519980058f5144985278e7f3e1 100644 (file)
@@ -61,8 +61,8 @@ Rating::Rating (cxml::ConstNodePtr node)
 void
 Rating::as_xml (xmlpp::Element* parent) const
 {
-       parent->add_child("Agency")->add_child_text(agency);
-       parent->add_child("Label")->add_child_text(label);
+       cxml::add_text_child(parent, "Agency", agency);
+       cxml::add_text_child(parent, "Label", label);
 }
 
 
index a8481d593f03db5a8f60517353da65a7d8fd3508..def3a4ae6a18104f9860e79367286f49e9838b51 100644 (file)
@@ -141,9 +141,9 @@ Reel::Reel (std::shared_ptr<const cxml::Node> node, dcp::Standard standard)
 xmlpp::Element *
 Reel::write_to_cpl (xmlpp::Element* node, Standard standard) const
 {
-       auto reel = node->add_child ("Reel");
-       reel->add_child("Id")->add_child_text("urn:uuid:" + _id);
-       xmlpp::Element* asset_list = reel->add_child ("AssetList");
+       auto reel = cxml::add_child(node, "Reel");
+       cxml::add_text_child(reel, "Id", "urn:uuid:" + _id);
+       auto asset_list = cxml::add_child(reel, "AssetList");
 
        if (_main_markers) {
                _main_markers->write_to_cpl (asset_list, standard);
index 3a3ae7312fd131b070085b41577ca1db8349d0db..c782cf2b3478087c39bc3091c083addf87d985c0 100644 (file)
@@ -84,10 +84,10 @@ ReelAsset::ReelAsset (shared_ptr<const cxml::Node> node)
 }
 
 
-xmlpp::Node*
-ReelAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+xmlpp::Element*
+ReelAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
 {
-       auto a = node->add_child (cpl_node_name (standard));
+       auto a = cxml::add_child(node, cpl_node_name(standard));
        auto const attr = cpl_node_attribute (standard);
        if (!attr.first.empty ()) {
                a->set_attribute (attr.first, attr.second);
@@ -96,18 +96,18 @@ ReelAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
        if (!ns.first.empty()) {
                a->set_namespace_declaration (ns.first, ns.second);
        }
-       a->add_child("Id")->add_child_text ("urn:uuid:" + _id);
+       cxml::add_text_child(a, "Id", "urn:uuid:" + _id);
        /* Empty <AnnotationText> tags cause refusal to play on some Sony SRX320 / LMT3000 systems (DoM bug #2124) */
        if (_annotation_text && !_annotation_text->empty()) {
-               a->add_child("AnnotationText")->add_child_text(*_annotation_text);
+               cxml::add_text_child(a, "AnnotationText", *_annotation_text);
        }
-       a->add_child("EditRate")->add_child_text (_edit_rate.as_string());
-       a->add_child("IntrinsicDuration")->add_child_text (raw_convert<string> (_intrinsic_duration));
+       cxml::add_text_child(a, "EditRate", _edit_rate.as_string());
+       cxml::add_text_child(a, "IntrinsicDuration", raw_convert<string>(_intrinsic_duration));
        if (_entry_point) {
-               a->add_child("EntryPoint")->add_child_text(raw_convert<string>(*_entry_point));
+               cxml::add_text_child(a, "EntryPoint", raw_convert<string>(*_entry_point));
        }
        if (_duration) {
-               a->add_child("Duration")->add_child_text(raw_convert<string>(*_duration));
+               cxml::add_text_child(a, "Duration", raw_convert<string>(*_duration));
        }
        return a;
 }
index e928cb18542694a5bc7f7989be86f04a533e971f..8dad739e46bccb152147a23f0eb5a361b9d6a955 100644 (file)
@@ -83,7 +83,7 @@ public:
 
        explicit ReelAsset (std::shared_ptr<const cxml::Node>);
 
-       virtual xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const;
+       virtual xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const;
 
        virtual bool encryptable () const {
                return false;
index ef39a4eb91cc3c6597df93cb81cce778c44261fd..c2cdb7f30d4bdb6d07f9a880bfa1114285085c29 100644 (file)
@@ -82,11 +82,11 @@ ReelAtmosAsset::cpl_node_namespace () const
 }
 
 
-xmlpp::Node *
-ReelAtmosAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+xmlpp::Element*
+ReelAtmosAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
 {
        auto asset = ReelFileAsset::write_to_cpl (node, standard);
-       asset->add_child("axd:DataType")->add_child_text("urn:smpte:ul:060e2b34.04010105.0e090604.00000000");
+       cxml::add_text_child(asset, "axd:DataType", "urn:smpte:ul:060e2b34.04010105.0e090604.00000000");
        return asset;
 }
 
index 298cbbfd2b0f96625f7cbceff2dff693481297cf..c3de76a8ab5445647694e6c84572345ffc328a06 100644 (file)
@@ -68,7 +68,7 @@ public:
                return asset_of_type<AtmosAsset>();
        }
 
-       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override;
+       xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
        bool equals(std::shared_ptr<const ReelAtmosAsset>, EqualityOptions const&, NoteHandler) const;
 
 private:
index 5fefda2752daebcaadac5553dec8b6c952d3863c..8fed8012109216b2a2a10edf728b2e7be959240b 100644 (file)
@@ -94,15 +94,15 @@ ReelFileAsset::file_asset_equals(shared_ptr<const ReelFileAsset> other, Equality
 }
 
 
-xmlpp::Node *
-ReelFileAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+xmlpp::Element*
+ReelFileAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
 {
-       auto asset = ReelAsset::write_to_cpl (node, standard);
+       auto asset = ReelAsset::write_to_cpl(node, standard);
         if (_key_id) {
-               asset->add_child("KeyId")->add_child_text("urn:uuid:" + *_key_id);
+               cxml::add_text_child(asset, "KeyId", "urn:uuid:" + *_key_id);
         }
        if (_hash) {
-               asset->add_child("Hash")->add_child_text(*_hash);
+               cxml::add_text_child(asset, "Hash", *_hash);
        }
        return asset;
 }
index 687e0d3eb8fe896134d5aae2f9d37aaffde1ea55..48fdf215fd9ff1c1238edada88dcf5ffad585b0b 100644 (file)
@@ -56,7 +56,7 @@ public:
        ReelFileAsset (std::shared_ptr<Asset> asset, boost::optional<std::string> key_id, std::string id, Fraction edit_rate, int64_t intrinsic_duration, int64_t entry_point);
        explicit ReelFileAsset (std::shared_ptr<const cxml::Node> node);
 
-       virtual xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override;
+       virtual xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
 
        /** @return a Ref to our actual asset */
        Ref const & asset_ref () const {
index be968068eed92f1dfa122502dab0710ab6f5c45e..c4539fd76c3072bf0bbc17eb05405049d238ddc7 100644 (file)
@@ -75,12 +75,12 @@ ReelInteropClosedCaptionAsset::cpl_node_namespace () const
 }
 
 
-xmlpp::Node *
-ReelInteropClosedCaptionAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+xmlpp::Element*
+ReelInteropClosedCaptionAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
 {
        auto asset = ReelClosedCaptionAsset::write_to_cpl (node, standard);
        if (_language) {
-               asset->add_child("Language")->add_child_text(*_language);
+               cxml::add_text_child(asset, "Language", *_language);
        }
        return asset;
 }
index 5e8f7c1ef306045dce6d1d8b39d84319fec18896..5a074357e5328708d37797870167fac1f0db53ab 100644 (file)
@@ -62,7 +62,7 @@ public:
                return asset_of_type<InteropSubtitleAsset>();
        }
 
-       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override;
+       xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
 
 private:
        std::string cpl_node_name (Standard) const override;
index d71a22ec892dccc6ab91b9c9b2b3d072f2c7563f..4b1b347227879191ec9263ea64e3faafdc344212 100644 (file)
@@ -104,16 +104,16 @@ ReelMarkersAsset::get (Marker m) const
 }
 
 
-xmlpp::Node*
-ReelMarkersAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+xmlpp::Element*
+ReelMarkersAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
 {
        int const tcr = edit_rate().numerator / edit_rate().denominator;
        auto asset = ReelAsset::write_to_cpl (node, standard);
-       auto ml = asset->add_child("MarkerList");
+       auto ml = cxml::add_child(asset, "MarkerList");
        for (auto const& i: _markers) {
-               auto m = ml->add_child("Marker");
-               m->add_child("Label")->add_child_text(marker_to_string(i.first));
-               m->add_child("Offset")->add_child_text(raw_convert<string>(i.second.as_editable_units_ceil(tcr)));
+               auto m = cxml::add_child(ml, "Marker");
+               cxml::add_text_child(m, "Label", marker_to_string(i.first));
+               cxml::add_text_child(m, "Offset", raw_convert<string>(i.second.as_editable_units_ceil(tcr)));
        }
 
        return asset;
index 2a1480a2d0d8c3bff22af163651148d73422112d..1e87957af917f4626996ce9e32a11ec1cbe4b4ec 100644 (file)
@@ -51,7 +51,7 @@ public:
        ReelMarkersAsset (Fraction edit_rate, int64_t intrinsic_duration);
        explicit ReelMarkersAsset (std::shared_ptr<const cxml::Node>);
 
-       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override;
+       xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
        bool equals(std::shared_ptr<const ReelMarkersAsset>, EqualityOptions const&, NoteHandler) const;
 
        void set (Marker, Time);
index eb87d03949b2a67be36c97d9133bdb78e5ff60d5..7ee5fa38fe5c2ef3d1b4b6c123ffbd434942be39 100644 (file)
@@ -86,12 +86,12 @@ ReelPictureAsset::ReelPictureAsset (shared_ptr<const cxml::Node> node)
 }
 
 
-xmlpp::Node*
-ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+xmlpp::Element*
+ReelPictureAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
 {
        auto asset = ReelFileAsset::write_to_cpl (node, standard);
 
-       asset->add_child("FrameRate")->add_child_text(String::compose("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
+       cxml::add_text_child(asset, "FrameRate", String::compose("%1 %2", _frame_rate.numerator, _frame_rate.denominator));
 
        if (standard == Standard::INTEROP) {
 
@@ -113,10 +113,12 @@ ReelPictureAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
                        }
                }
 
-               asset->add_child("ScreenAspectRatio")->add_child_text(raw_convert<string>(closest.get(), 2, true));
+               cxml::add_text_child(asset, "ScreenAspectRatio", raw_convert<string>(closest.get(), 2, true));
        } else {
-               asset->add_child("ScreenAspectRatio")->add_child_text(
-                       String::compose ("%1 %2", _screen_aspect_ratio.numerator, _screen_aspect_ratio.denominator)
+               cxml::add_text_child(
+                       asset,
+                       "ScreenAspectRatio",
+                       String::compose("%1 %2", _screen_aspect_ratio.numerator, _screen_aspect_ratio.denominator)
                        );
        }
 
index bf7d40aacb8010273bda2c5e5bb4ef70f28778f1..ebfef74492ef25f178c2a6321c15c883b579e393 100644 (file)
@@ -67,7 +67,7 @@ public:
                return asset_of_type<PictureAsset>();
        }
 
-       virtual xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override;
+       virtual xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
        bool equals(std::shared_ptr<const ReelPictureAsset>, EqualityOptions const&, NoteHandler) const;
 
        /** @return picture frame rate */
index a2a68202a997a5e5dff7f94cfeab085d7156e8f5..70e5eb365d38998a6c8c01c4d410151217ab2014 100644 (file)
@@ -65,12 +65,12 @@ ReelSMPTEClosedCaptionAsset::ReelSMPTEClosedCaptionAsset (shared_ptr<const cxml:
 }
 
 
-xmlpp::Node *
-ReelSMPTEClosedCaptionAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+xmlpp::Element*
+ReelSMPTEClosedCaptionAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
 {
        auto asset = ReelClosedCaptionAsset::write_to_cpl (node, standard);
        if (_language) {
-               asset->add_child("Language", "tt")->add_child_text(*_language);
+               cxml::add_child(asset, "Language", string("tt"))->add_child_text(*_language);
        }
        return asset;
 }
index 32a79efd2588ccf8229edd6a84ad2e25e67b200f..e7a26f65ea9c1f8090c0b439a1e91f06c80184d7 100644 (file)
@@ -63,7 +63,7 @@ public:
                return asset_of_type<const SMPTESubtitleAsset>();
        }
 
-       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override;
+       xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
 
 
 private:
index d856a05e0bf1f9f7f1575b6feb7796dcec597aa6..436aa69f6c84458589d5c7eee36c37ed5770949b 100644 (file)
@@ -103,12 +103,12 @@ ReelSubtitleAsset::equals(shared_ptr<const ReelSubtitleAsset> other, EqualityOpt
 }
 
 
-xmlpp::Node *
-ReelSubtitleAsset::write_to_cpl (xmlpp::Node* node, Standard standard) const
+xmlpp::Element *
+ReelSubtitleAsset::write_to_cpl(xmlpp::Element* node, Standard standard) const
 {
        auto asset = ReelFileAsset::write_to_cpl (node, standard);
        if (_language) {
-               asset->add_child("Language")->add_child_text(*_language);
+               cxml::add_text_child(asset, "Language", *_language);
        }
        return asset;
 }
index 8b694fd675494ecac9bc9b419faeaedcd4e71d90..c619c7522fe0ab623239ea60ebe6252e7160218f 100644 (file)
@@ -73,7 +73,7 @@ public:
                return asset_of_type<SubtitleAsset>();
        }
 
-       xmlpp::Node* write_to_cpl (xmlpp::Node* node, Standard standard) const override;
+       xmlpp::Element* write_to_cpl(xmlpp::Element* node, Standard standard) const override;
 
        bool equals(std::shared_ptr<const ReelSubtitleAsset>, EqualityOptions const&, NoteHandler) const;
 
index 0ff1d7ef5048996e7861e2bd7c02e453e68d66de..06c91c0b2c414a9aa02453dc2fed020b8f5cc674 100644 (file)
@@ -369,31 +369,31 @@ SMPTESubtitleAsset::xml_as_string () const
        auto root = doc.create_root_node ("SubtitleReel");
 
        DCP_ASSERT (_xml_id);
-       root->add_child("Id")->add_child_text("urn:uuid:" + *_xml_id);
-       root->add_child("ContentTitleText")->add_child_text(_content_title_text);
+       cxml::add_text_child(root, "Id", "urn:uuid:" + *_xml_id);
+       cxml::add_text_child(root, "ContentTitleText", _content_title_text);
        if (_annotation_text) {
-               root->add_child("AnnotationText")->add_child_text(_annotation_text.get());
+               cxml::add_text_child(root, "AnnotationText", _annotation_text.get());
        }
-       root->add_child("IssueDate")->add_child_text(_issue_date.as_string(false, false));
+       cxml::add_text_child(root, "IssueDate", _issue_date.as_string(false, false));
        if (_reel_number) {
-               root->add_child("ReelNumber")->add_child_text(raw_convert<string>(_reel_number.get()));
+               cxml::add_text_child(root, "ReelNumber", raw_convert<string>(_reel_number.get()));
        }
        if (_language) {
-               root->add_child("Language")->add_child_text(_language.get());
+               cxml::add_text_child(root, "Language", _language.get());
        }
-       root->add_child("EditRate")->add_child_text(_edit_rate.as_string());
-       root->add_child("TimeCodeRate")->add_child_text(raw_convert<string>(_time_code_rate));
+       cxml::add_text_child(root, "EditRate", _edit_rate.as_string());
+       cxml::add_text_child(root, "TimeCodeRate", raw_convert<string>(_time_code_rate));
        if (_start_time) {
-               root->add_child("StartTime")->add_child_text(_start_time.get().as_string(Standard::SMPTE));
+               cxml::add_text_child(root, "StartTime", _start_time.get().as_string(Standard::SMPTE));
        }
 
        for (auto i: _load_font_nodes) {
-               auto load_font = root->add_child("LoadFont");
+               auto load_font = cxml::add_child(root, "LoadFont");
                load_font->add_child_text ("urn:uuid:" + i->urn);
                load_font->set_attribute ("ID", i->id);
        }
 
-       subtitles_as_xml (root->add_child("SubtitleList"), _time_code_rate, Standard::SMPTE);
+       subtitles_as_xml(cxml::add_child(root, "SubtitleList"), _time_code_rate, Standard::SMPTE);
 
        return format_xml(doc, std::make_pair(string{}, schema_namespace()));
 }
index 99d8411b3614789d2812b26137d5a2c89c552626..39f68624f3e4fd9091ab6ede7f64e226c9e034fd 100644 (file)
@@ -77,7 +77,7 @@ order::Font::Font (shared_ptr<SubtitleString> s, Standard standard)
 xmlpp::Element*
 order::Font::as_xml (xmlpp::Element* parent, Context&) const
 {
-       auto e = parent->add_child("Font");
+       auto e = cxml::add_child(parent, "Font");
        for (const auto& i: _values) {
                e->set_attribute (i.first, i.second);
        }
@@ -137,7 +137,7 @@ xmlpp::Element*
 order::String::as_xml (xmlpp::Element* parent, Context& context) const
 {
        if (fabs(_space_before) > SPACE_BEFORE_EPSILON) {
-               auto space = parent->add_child("Space");
+               auto space = cxml::add_child(parent, "Space");
                auto size = raw_convert<string>(_space_before, 2);
                if (context.standard == Standard::INTEROP) {
                        size += "em";
@@ -212,7 +212,7 @@ position_align (xmlpp::Element* e, order::Context& context, HAlign h_align, floa
 xmlpp::Element*
 order::Text::as_xml (xmlpp::Element* parent, Context& context) const
 {
-       auto e = parent->add_child ("Text");
+       auto e = cxml::add_child(parent, "Text");
 
        position_align(e, context, _h_align, _h_position, _v_align, _v_position, _z_position);
 
@@ -224,9 +224,9 @@ order::Text::as_xml (xmlpp::Element* parent, Context& context) const
        }
 
        for (auto const& ruby: _rubies) {
-               auto xml = e->add_child("Ruby");
-               xml->add_child("Rb")->add_child_text(ruby.base);
-               auto rt = xml->add_child("Rt");
+               auto xml = cxml::add_child(e, "Ruby");
+               cxml::add_child(xml, "Rb")->add_child_text(ruby.base);
+               auto rt = cxml::add_child(xml, "Rt");
                rt->add_child_text(ruby.annotation);
                rt->set_attribute("Size", dcp::raw_convert<string>(ruby.size, 6));
                rt->set_attribute("Position", ruby.position == RubyPosition::BEFORE ? "before" : "after");
@@ -242,7 +242,7 @@ order::Text::as_xml (xmlpp::Element* parent, Context& context) const
 xmlpp::Element*
 order::Subtitle::as_xml (xmlpp::Element* parent, Context& context) const
 {
-       auto e = parent->add_child ("Subtitle");
+       auto e = cxml::add_child(parent, "Subtitle");
        e->set_attribute ("SpotNumber", raw_convert<string> (context.spot_number++));
        e->set_attribute ("TimeIn", _in.rebase(context.time_code_rate).as_string(context.standard));
        e->set_attribute ("TimeOut", _out.rebase(context.time_code_rate).as_string(context.standard));
@@ -274,7 +274,7 @@ order::Font::clear ()
 xmlpp::Element *
 order::Image::as_xml (xmlpp::Element* parent, Context& context) const
 {
-       auto e = parent->add_child ("Image");
+       auto e = cxml::add_child(parent, "Image");
 
        position_align(e, context, _h_align, _h_position, _v_align, _v_position, _z_position);
        if (context.standard == Standard::SMPTE) {
index f4bf8db0504f68555bccb4164fa566fa1c7166dc..c4ba88862e7ea7c646142e88b2746659734127a6 100644 (file)
@@ -310,9 +310,9 @@ ContentVersion::ContentVersion (string label_text_)
 void
 ContentVersion::as_xml (xmlpp::Element* parent) const
 {
-       auto cv = parent->add_child("ContentVersion");
-       cv->add_child("Id")->add_child_text(id);
-       cv->add_child("LabelText")->add_child_text(label_text);
+       auto cv = cxml::add_child(parent, "ContentVersion");
+       cxml::add_text_child(cv, "Id", id);
+       cxml::add_text_child(cv, "LabelText", label_text);
 }
 
 
@@ -345,7 +345,7 @@ Luminance::set_value (float v)
 void
 Luminance::as_xml (xmlpp::Element* parent, string ns) const
 {
-       auto lum = parent->add_child("Luminance", ns);
+       auto lum = cxml::add_child(parent, "Luminance", ns);
        lum->set_attribute("units", unit_to_string(_unit));
        lum->add_child_text(raw_convert<string>(_value, 3));
 }
index 7ac20e1071bf04f9e74b438db15b90e8a85f7769..22ee71775955f1728034f93aa41589f4a94adee6 100644 (file)
@@ -175,13 +175,13 @@ BOOST_AUTO_TEST_CASE (format_xml_test1)
 {
        xmlpp::Document doc;
        auto root = doc.create_root_node("Foo");
-       root->add_child("Empty");
-       root->add_child("Text")->add_child_text("Hello world");
-       root->add_child("Font")->add_child("Text")->add_child_text("Say what");
-       auto fred = root->add_child("Text")->add_child("Font");
+       cxml::add_child(root, "Empty");
+       cxml::add_text_child(root, "Text", "Hello world");
+       cxml::add_text_child(cxml::add_child(root, "Font"), "Text", "Say what");
+       auto fred = cxml::add_child(cxml::add_child(root, "Text"), "Font");
        fred->set_attribute("bob", "job");
        fred->add_child_text("Fred");
-       fred->add_child("Text")->add_child_text("Jim");
+       cxml::add_text_child(fred, "Text", "Jim");
        fred->add_child_text("Sheila");
        BOOST_REQUIRE_EQUAL (dcp::SubtitleAsset::format_xml(doc, make_pair(string{}, string{"fred"})),
 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
@@ -210,7 +210,7 @@ BOOST_AUTO_TEST_CASE (format_xml_entities_test)
 {
        xmlpp::Document doc;
        auto root = doc.create_root_node("Foo");
-       root->add_child("Bar")->add_child_text("Don't panic &amp; xml \"is\" 'great' & < > —");
+       cxml::add_text_child(root, "Bar", "Don't panic &amp; xml \"is\" 'great' & < > —");
        BOOST_REQUIRE_EQUAL(dcp::SubtitleAsset::format_xml(doc, {}),
 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
 "<Foo>\n"