Merge branch 'master' of ssh://main.carlh.net/home/carl/git/libdcp
[libdcp.git] / src / types.cc
index cbb56e7fe2f0ebbf157523b218ab2590ff04f363..a7c621ffc688d02b6841a2e6ffa851ae572c004a 100644 (file)
@@ -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 <numerator> <denominator>
  *  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.