/*
- Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
_content_version_label_text = content_version->string_child ("LabelText");
content_version->done ();
}
- f.ignore_child ("RatingList");
+ cxml::ConstNodePtr rating_list = f.node_child ("RatingList");
+ if (rating_list) {
+ BOOST_FOREACH (cxml::ConstNodePtr i, rating_list->node_children("Rating")) {
+ _ratings.push_back (Rating(i));
+ }
+ }
_reels = type_grand_children<Reel> (f, "ReelList", "Reel");
f.ignore_child ("Issuer");
cv->add_child ("Id")->add_child_text (_content_version_id);
cv->add_child ("LabelText")->add_child_text (_content_version_label_text);
}
- root->add_child("RatingList");
+ xmlpp::Element* rating_list = root->add_child("RatingList");
+ BOOST_FOREACH (Rating i, _ratings) {
+ i.as_xml (rating_list->add_child("Rating"));
+ }
xmlpp::Element* reel_list = root->add_child ("ReelList");
return _standard;
}
+ std::list<Rating> ratings () const {
+ return _ratings;
+ }
+
+ void set_ratings (std::list<Rating> r) {
+ _ratings = r;
+ }
+
static std::string static_pkl_type (Standard standard);
protected:
std::string _content_version_id; ///< <Id> in <ContentVersion>
std::string _content_version_label_text; ///< <LabelText> in <ContentVersion>
std::list<boost::shared_ptr<Reel> > _reels;
+ std::list<Rating> _ratings;
/** Standard of CPL that was read in */
boost::optional<Standard> _standard;
/*
- Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2019 Carl Hetherington <cth@carlh.net>
This file is part of libdcp.
#include "exceptions.h"
#include "compose.hpp"
#include "dcp_assert.h"
+#include <libxml++/libxml++.h>
#include <boost/algorithm/string.hpp>
#include <vector>
#include <cstdio>
DCP_ASSERT (false);
}
+
+Rating::Rating (cxml::ConstNodePtr node)
+{
+ agency = node->string_child("Agency");
+ label = node->string_child("Label");
+ node->done ();
+}
+
+void
+Rating::as_xml (xmlpp::Element* parent) const
+{
+ parent->add_child("Agency")->add_child_text(agency);
+ parent->add_child("Label")->add_child_text(label);
+}
+
+bool
+dcp::operator== (Rating const & a, Rating const & b)
+{
+ return a.agency == b.agency && a.label == b.label;
+}
+
+ostream &
+dcp::operator<< (ostream& s, Rating const & r)
+{
+ s << r.agency << " " << r.label;
+ return s;
+}
#ifndef LIBDCP_TYPES_H
#define LIBDCP_TYPES_H
+#include <libcxml/cxml.h>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <string>
+namespace xmlpp {
+ class Element;
+}
+
namespace dcp
{
std::string marker_to_string (Marker);
Marker marker_from_string (std::string);
+class Rating
+{
+public:
+ Rating (std::string agency_, std::string label_)
+ : agency (agency_)
+ , label (label_)
+ {}
+
+ explicit Rating (cxml::ConstNodePtr node);
+
+ void as_xml (xmlpp::Element* parent) const;
+
+ /** URI of the agency issuing the rating */
+ std::string agency;
+ /** Rating (e.g. PG, PG-13, 12A etc) */
+ std::string label;
+};
+
+extern bool operator== (Rating const & a, Rating const & b);
+extern std::ostream& operator<< (std::ostream& s, Rating const & r);
+
}
#endif
colour_test.cc
colour_conversion_test.cc
cpl_sar_test.cc
+ cpl_ratings_test.cc
dcp_font_test.cc
dcp_test.cc
dcp_time_test.cc