X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fdcpomatic_time.h;h=893bce2572e21752a1de59f6dcdb43f9eb8a0ca4;hb=332ad44023ff81ae44b15f2587f4d40e4d5ccff5;hp=a94b605d2b94f61d7a1eebb68d0835d7856174ac;hpb=9c01623c3038b978ba732de2ad147d29fad60afe;p=dcpomatic.git diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index a94b605d2..893bce257 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2014-2015 Carl Hetherington + Copyright (C) 2014-2016 Carl Hetherington This file is part of DCP-o-matic. @@ -27,12 +27,12 @@ #include "frame_rate_change.h" #include "dcpomatic_assert.h" -#include #include #include #include #include #include +#include class dcpomatic_round_up_test; @@ -182,14 +182,9 @@ public: int f; split (r, h, m, s, f); - locked_stringstream o; - o.width (2); - o.fill ('0'); - o << std::setw(2) << std::setfill('0') << h << ":" - << std::setw(2) << std::setfill('0') << m << ":" - << std::setw(2) << std::setfill('0') << s << ":" - << std::setw(2) << std::setfill('0') << f; - return o.str (); + char buffer[128]; + snprintf (buffer, sizeof (buffer), "%02d:%02d:%02d:%02d", h, m, s, f); + return buffer; } @@ -277,9 +272,20 @@ public: return (from <= other && other < to); } + bool operator< (TimePeriod const & o) const { + if (from != o.from) { + return from < o.from; + } + return to < o.to; + } + bool operator== (TimePeriod const & other) const { return from == other.from && to == other.to; } + + bool operator!= (TimePeriod const & other) const { + return !(*this == other); + } }; typedef TimePeriod ContentTimePeriod; @@ -289,8 +295,8 @@ DCPTime min (DCPTime a, DCPTime b); DCPTime max (DCPTime a, DCPTime b); ContentTime min (ContentTime a, ContentTime b); ContentTime max (ContentTime a, ContentTime b); -std::ostream& operator<< (std::ostream& s, ContentTime t); -std::ostream& operator<< (std::ostream& s, DCPTime t); -std::ostream& operator<< (std::ostream& s, DCPTimePeriod p); +std::string to_string (ContentTime t); +std::string to_string (DCPTime t); +std::string to_string (DCPTimePeriod p); #endif