38 #include <libcxml/cxml.h>
39 #include <boost/algorithm/string.hpp>
44 using boost::algorithm::trim;
45 using boost::optional;
49 static vector<RatingSystem> rating_systems_list;
52 Rating::Rating (cxml::ConstNodePtr node)
53 : agency(node->string_child(
"Agency"))
54 , label(node->string_child(
"Label"))
61 Rating::as_xml (xmlpp::Element* parent)
const
63 parent->add_child(
"Agency")->add_child_text(
agency);
64 parent->add_child(
"Label")->add_child_text(
label);
78 return rating_systems_list;
83 dcp::load_rating_list(boost::filesystem::path ratings_file)
87 throw FileError (
"Could not open ratings file", ratings_file, errno);
90 auto get_line_no_throw = [f, ratings_file]() -> optional<string> {
92 char* r = fgets(buffer,
sizeof(buffer), f);
101 auto get_line = [ratings_file, &get_line_no_throw]() {
102 auto line = get_line_no_throw();
104 throw FileError(
"Bad ratings file", ratings_file, -1);
109 optional<string> agency;
115 auto name = get_line();
116 auto country_and_region_names = get_line();
117 auto country_code = get_line();
119 RatingSystem system(*agency, name, country_and_region_names, country_code);
121 auto rating = get_line_no_throw();
126 if (rating->substr(0, 4) ==
"http") {
131 system.ratings.push_back(
dcp::Rating(*agency, *rating));
134 rating_systems_list.push_back(system);
An exception related to a file.
Exceptions thrown by libdcp.
Namespace for everything in libdcp.
FILE * fopen_boost(boost::filesystem::path, std::string)
Utility methods and classes.