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 /src | |
| parent | 81badfe68a8de71e8c1a89bd63187231a3691d77 (diff) | |
Make CPL annotation_text optional.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 8 | ||||
| -rw-r--r-- | src/cpl.h | 6 |
2 files changed, 8 insertions, 6 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; |
