4 #include <boost/lexical_cast.hpp>
5 #include <boost/algorithm/string.hpp>
7 #include "exceptions.h"
10 using namespace libdcp;
11 using namespace boost;
13 Fraction::Fraction (string s)
16 split (b, s, is_any_of (" "));
18 throw XMLError ("malformed fraction " + s + " in XML node");
20 numerator = lexical_cast<int> (b[0]);
21 denominator = lexical_cast<int> (b[1]);
25 libdcp::operator== (Fraction const & a, Fraction const & b)
27 return (a.numerator == b.numerator && a.denominator == b.denominator);
31 libdcp::operator!= (Fraction const & a, Fraction const & b)
33 return (a.numerator != b.numerator || a.denominator != b.denominator);
44 Color::Color (int r_, int g_, int b_)
52 Color::Color (string argb_hex)
55 if (sscanf (argb_hex.c_str(), "%2x%2x%2x%2x", &alpha, &r, &g, &b) < 4) {
56 throw XMLError ("could not parse colour string");
61 Color::to_argb_string () const
66 << setw(2) << setfill('0') << r
67 << setw(2) << setfill('0') << g
68 << setw(2) << setfill('0') << b;
76 libdcp::operator== (Color const & a, Color const & b)
78 return (a.r == b.r && a.g == b.g && a.b == b.b);
82 libdcp::operator!= (Color const & a, Color const & b)
88 libdcp::operator<< (ostream& s, Color const & c)
90 s << "(" << c.r << ", " << c.g << ", " << c.b << ")";
95 libdcp::effect_to_string (Effect e)
106 throw MiscError ("unknown effect type");
110 libdcp::string_to_effect (string s)
114 } else if (s == "border") {
116 } else if (s == "shadow") {
120 throw DCPReadError ("unknown subtitle effect type");
124 libdcp::valign_to_string (VAlign v)
135 throw MiscError ("unknown valign type");
139 libdcp::string_to_valign (string s)
143 } else if (s == "center") {
145 } else if (s == "bottom") {
149 throw DCPReadError ("unknown subtitle valign type");