diff options
| author | Carl Hetherington <cth@carlh.net> | 2020-08-26 23:02:10 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2020-09-21 21:57:18 +0200 |
| commit | 0fa60920228c591f1183149d79c88302d3ce01fb (patch) | |
| tree | afedcb6e3dbae9011e246b21c23839af687939c4 /src | |
| parent | e18addc9029f56c67aa40254bcfa40f8b072866f (diff) | |
Add ContentVersion class.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cpl.cc | 15 | ||||
| -rw-r--r-- | src/cpl.h | 18 | ||||
| -rw-r--r-- | src/types.cc | 10 | ||||
| -rw-r--r-- | src/types.h | 17 |
4 files changed, 39 insertions, 21 deletions
@@ -75,8 +75,8 @@ CPL::CPL (string annotation_text, ContentKind content_kind) a random ID and the current time. */ string const uuid = make_uuid(); - _content_version_id = "urn:uuid:" + uuid; - _content_version_label_text = uuid + LocalTime().as_string (); + _content_version.id = "urn:uuid:" + uuid; + _content_version.label_text = uuid + LocalTime().as_string (); } /** Construct a CPL object from a XML file */ @@ -104,8 +104,8 @@ CPL::CPL (boost::filesystem::path file) _content_kind = content_kind_from_string (f.string_child ("ContentKind")); shared_ptr<cxml::Node> content_version = f.optional_node_child ("ContentVersion"); if (content_version) { - _content_version_id = content_version->optional_string_child ("Id").get_value_or (""); - _content_version_label_text = content_version->string_child ("LabelText"); + _content_version.id = content_version->optional_string_child("Id").get_value_or(""); + _content_version.label_text = content_version->string_child("LabelText"); content_version->done (); } else if (_standard == SMPTE) { /* ContentVersion is required in SMPTE */ @@ -158,11 +158,8 @@ CPL::write_xml (boost::filesystem::path file, Standard standard, shared_ptr<cons root->add_child("Creator")->add_child_text (_creator); root->add_child("ContentTitleText")->add_child_text (_content_title_text); root->add_child("ContentKind")->add_child_text (content_kind_to_string (_content_kind)); - { - xmlpp::Node* cv = root->add_child ("ContentVersion"); - cv->add_child ("Id")->add_child_text (_content_version_id); - cv->add_child ("LabelText")->add_child_text (_content_version_label_text); - } + _content_version.as_xml (root); + xmlpp::Element* rating_list = root->add_child("RatingList"); BOOST_FOREACH (Rating i, _ratings) { i.as_xml (rating_list->add_child("Rating")); @@ -104,14 +104,9 @@ public: _content_title_text = ct; } - /** @return contents of the <Id> node within <ContentVersion> */ - void set_content_version_id (std::string id) { - _content_version_id = id; - } - - /** @return contents of the <LabelText> node within <ContentVersion> */ - void set_content_version_label_text (std::string text) { - _content_version_label_text = text; + /** Set the contents of the ContentVersion tag */ + void set_content_version (ContentVersion v) { + _content_version = v; } /** @return the type of the content, used by media servers @@ -155,8 +150,8 @@ public: _ratings = r; } - std::string content_version_label_text () const { - return _content_version_label_text; + ContentVersion content_version () const { + return _content_version; } static std::string static_pkl_type (Standard standard); @@ -172,8 +167,7 @@ private: std::string _annotation_text; std::string _content_title_text; ///< <ContentTitleText> ContentKind _content_kind; ///< <ContentKind> - std::string _content_version_id; ///< <Id> in <ContentVersion> - std::string _content_version_label_text; ///< <LabelText> in <ContentVersion> + ContentVersion _content_version; ///< <ContentVersion> std::list<boost::shared_ptr<Reel> > _reels; std::list<Rating> _ratings; diff --git a/src/types.cc b/src/types.cc index b329396d..746b6f6a 100644 --- a/src/types.cc +++ b/src/types.cc @@ -462,3 +462,13 @@ dcp::operator<< (ostream& s, Rating const & r) s << r.agency << " " << r.label; return s; } + + +void +ContentVersion::as_xml (xmlpp::Element* parent) const +{ + xmlpp::Node* cv = parent->add_child("ContentVersion"); + cv->add_child("Id")->add_child_text(id); + cv->add_child("LabelText")->add_child_text(label_text); +} + diff --git a/src/types.h b/src/types.h index c600b790..7b2faa7c 100644 --- a/src/types.h +++ b/src/types.h @@ -322,6 +322,23 @@ public: extern bool operator== (Rating const & a, Rating const & b); extern std::ostream& operator<< (std::ostream& s, Rating const & r); + +class ContentVersion +{ +public: + ContentVersion () {} + + ContentVersion (std::string id_, std::string label_text_) + : id (id_) + , label_text (label_text_) + {} + + void as_xml (xmlpp::Element* parent) const; + + std::string id; + std::string label_text; +}; + } #endif |
