summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-01-14 22:20:06 +0100
committerCarl Hetherington <cth@carlh.net>2021-01-17 20:13:23 +0100
commitad03415009155f8771ca48200f3c4a469c85277e (patch)
treebd767c876112cfd6649f381ce31ca4ce30952c07 /src
parent81badfe68a8de71e8c1a89bd63187231a3691d77 (diff)
Make CPL annotation_text optional.
Diffstat (limited to 'src')
-rw-r--r--src/cpl.cc8
-rw-r--r--src/cpl.h6
2 files changed, 8 insertions, 6 deletions
diff --git a/src/cpl.cc b/src/cpl.cc
index 04bc9f5c..caf4be1e 100644
--- a/src/cpl.cc
+++ b/src/cpl.cc
@@ -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;
}
diff --git a/src/cpl.h b/src/cpl.h
index c2a8b07d..3bfffcb5 100644
--- a/src/cpl.h
+++ b/src/cpl.h
@@ -117,8 +117,8 @@ public:
_issue_date = issue_date;
}
- /** @return contents of the &lt;AnnotationText&gt; node */
- std::string annotation_text () const {
+ /** @return contents of the &lt;AnnotationText&gt; 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; ///< &lt;ContentTitleText&gt;
ContentKind _content_kind; ///< &lt;ContentKind&gt;
std::vector<ContentVersion> _content_versions;