X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftypes.cc;h=a7c621ffc688d02b6841a2e6ffa851ae572c004a;hb=9facd099fd1b0651af721883ea1ffe5590d4b23b;hp=cbb56e7fe2f0ebbf157523b218ab2590ff04f363;hpb=d927e9b913606f4fc982885c7582ecaf0e3c5a1a;p=libdcp.git diff --git a/src/types.cc b/src/types.cc index cbb56e7f..a7c621ff 100644 --- a/src/types.cc +++ b/src/types.cc @@ -44,6 +44,22 @@ using namespace std; using namespace dcp; using namespace boost; +bool dcp::operator== (dcp::Size const & a, dcp::Size const & b) +{ + return (a.width == b.width && a.height == b.height); +} + +bool dcp::operator!= (dcp::Size const & a, dcp::Size const & b) +{ + return !(a == b); +} + +ostream& dcp::operator<< (ostream& s, dcp::Size const & a) +{ + s << a.width << "x" << a.height; + return s; +} + /** Construct a Fraction from a string of the form * e.g. "1 3". */ @@ -121,16 +137,20 @@ Colour::Colour (string argb_hex) string Colour::to_argb_string () const { - stringstream s; - s << "FF"; - s << hex - << setw(2) << setfill('0') << r - << setw(2) << setfill('0') << g - << setw(2) << setfill('0') << b; - - string t = s.str(); - to_upper (t); - return t; + char buffer[9]; + snprintf (buffer, sizeof(buffer), "FF%02X%02X%02X", r, g, b); + return buffer; +} + +/** @return An RGB string of the form RRGGBB, where e.g. RR is a two-character + * hex value. + */ +string +Colour::to_rgb_string () const +{ + char buffer[7]; + snprintf (buffer, sizeof(buffer), "%02X%02X%02X", r, g, b); + return buffer; } /** operator== for Colours.