diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-01-14 22:20:06 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2021-01-17 20:13:23 +0100 |
| commit | ad03415009155f8771ca48200f3c4a469c85277e (patch) | |
| tree | bd767c876112cfd6649f381ce31ca4ce30952c07 | |
| parent | 81badfe68a8de71e8c1a89bd63187231a3691d77 (diff) | |
Make CPL annotation_text optional.
| -rw-r--r-- | src/cpl.cc | 8 | ||||
| -rw-r--r-- | src/cpl.h | 6 | ||||
| -rw-r--r-- | test/read_dcp_test.cc | 10 | ||||
| -rw-r--r-- | tools/dcpinfo.cc | 2 |
4 files changed, 15 insertions, 11 deletions
@@ -103,7 +103,7 @@ CPL::CPL (boost::filesystem::path file) } _id = remove_urn_uuid (f.string_child ("Id")); - _annotation_text = f.optional_string_child("AnnotationText").get_value_or(""); + _annotation_text = f.optional_string_child("AnnotationText"); _issuer = f.optional_string_child("Issuer").get_value_or(""); _creator = f.optional_string_child("Creator").get_value_or(""); _issue_date = f.string_child ("IssueDate"); @@ -178,7 +178,9 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons } root->add_child("Id")->add_child_text ("urn:uuid:" + _id); - root->add_child("AnnotationText")->add_child_text (_annotation_text); + if (_annotation_text) { + root->add_child("AnnotationText")->add_child_text (*_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); @@ -548,7 +550,7 @@ CPL::equals (shared_ptr<const Asset> other, EqualityOptions opt, NoteHandler not } if (_annotation_text != other_cpl->_annotation_text && !opt.cpl_annotation_texts_can_differ) { - string const s = "CPL: annotation texts differ: " + _annotation_text + " vs " + other_cpl->_annotation_text + "\n"; + string const s = "CPL: annotation texts differ: " + _annotation_text.get_value_or("") + " vs " + other_cpl->_annotation_text.get_value_or("") + "\n"; note (DCP_ERROR, s); return false; } @@ -117,8 +117,8 @@ public: _issue_date = issue_date; } - /** @return contents of the <AnnotationText> node */ - std::string annotation_text () const { + /** @return contents of the <AnnotationText> node, if present */ + boost::optional<std::string> annotation_text () const { return _annotation_text; } @@ -290,7 +290,7 @@ private: std::string _issuer; std::string _creator; std::string _issue_date; - std::string _annotation_text; + boost::optional<std::string> _annotation_text; std::string _content_title_text; ///< <ContentTitleText> ContentKind _content_kind; ///< <ContentKind> std::vector<ContentVersion> _content_versions; diff --git a/test/read_dcp_test.cc b/test/read_dcp_test.cc index 7eed18d0..b42a3c39 100644 --- a/test/read_dcp_test.cc +++ b/test/read_dcp_test.cc @@ -48,8 +48,9 @@ BOOST_AUTO_TEST_CASE (read_dcp_test1) auto cpls = d.cpls (); BOOST_CHECK_EQUAL (cpls.size(), 1); - BOOST_CHECK_EQUAL (cpls.front()->annotation_text(), "A Test DCP"); - BOOST_CHECK_EQUAL (cpls.front()->content_kind(), dcp::FEATURE); + BOOST_REQUIRE (cpls[0]->annotation_text()); + BOOST_CHECK_EQUAL (cpls[0]->annotation_text().get(), "A Test DCP"); + BOOST_CHECK_EQUAL (cpls[0]->content_kind(), dcp::FEATURE); BOOST_REQUIRE (d.standard()); BOOST_CHECK_EQUAL (d.standard(), dcp::SMPTE); } @@ -63,8 +64,9 @@ BOOST_AUTO_TEST_CASE (read_dcp_test2) auto cpls = d.cpls (); BOOST_CHECK_EQUAL (cpls.size(), 1); - BOOST_CHECK_EQUAL (cpls.front()->annotation_text(), "Test_FTR-1_F-119_10_2K_20160524_IOP_OV"); - BOOST_CHECK_EQUAL (cpls.front()->content_kind(), dcp::FEATURE); + BOOST_REQUIRE (cpls[0]->annotation_text()); + BOOST_CHECK_EQUAL (cpls[0]->annotation_text().get(), "Test_FTR-1_F-119_10_2K_20160524_IOP_OV"); + BOOST_CHECK_EQUAL (cpls[0]->content_kind(), dcp::FEATURE); BOOST_REQUIRE (d.standard()); BOOST_CHECK_EQUAL (d.standard(), dcp::INTEROP); } diff --git a/tools/dcpinfo.cc b/tools/dcpinfo.cc index 5ca9b24f..aa1ce8c2 100644 --- a/tools/dcpinfo.cc +++ b/tools/dcpinfo.cc @@ -397,7 +397,7 @@ main (int argc, char* argv[]) dcp::Time total_time; BOOST_FOREACH (shared_ptr<CPL> i, cpls) { - OUTPUT_CPL_NAME_ID(" CPL: %1 %2\n", i->annotation_text(), i->id()); + OUTPUT_CPL_NAME_ID(" CPL: %1 %2\n", i->annotation_text().get_value_or(""), i->id()); int R = 1; BOOST_FOREACH (shared_ptr<Reel> j, i->reels()) { |
