X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fdcpomatic_time.cc;h=8abd7755530165f2f13ba50aeefc4194bf9e0fe4;hb=f06c5136e7d3cd0a8e1814763c7774859998efe4;hp=f96688979c9504646437846b438738e719d5689f;hpb=3828baf56467224f5d44049bf1e7a7ed11f43a05;p=dcpomatic.git diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index f96688979..8abd77555 100644 --- a/src/lib/dcpomatic_time.cc +++ b/src/lib/dcpomatic_time.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2016 Carl Hetherington This file is part of DCP-o-matic. @@ -19,8 +19,10 @@ */ #include "dcpomatic_time.h" +#include -using std::ostream; +using std::string; +using namespace dcpomatic; template <> Time::Time (DCPTime d, FrameRateChange f) @@ -37,7 +39,7 @@ Time::Time (ContentTime d, Fra } DCPTime -min (DCPTime a, DCPTime b) +dcpomatic::min (DCPTime a, DCPTime b) { if (a < b) { return a; @@ -47,7 +49,7 @@ min (DCPTime a, DCPTime b) } DCPTime -max (DCPTime a, DCPTime b) +dcpomatic::max (DCPTime a, DCPTime b) { if (a > b) { return a; @@ -57,7 +59,7 @@ max (DCPTime a, DCPTime b) } ContentTime -min (ContentTime a, ContentTime b) +dcpomatic::min (ContentTime a, ContentTime b) { if (a < b) { return a; @@ -67,7 +69,7 @@ min (ContentTime a, ContentTime b) } ContentTime -max (ContentTime a, ContentTime b) +dcpomatic::max (ContentTime a, ContentTime b) { if (a > b) { return a; @@ -76,23 +78,38 @@ max (ContentTime a, ContentTime b) return b; } -ostream & -operator<< (ostream& s, ContentTime t) +string +dcpomatic::to_string (ContentTime t) { - s << "[CONT " << t.get() << " " << t.seconds() << "s]"; - return s; + char buffer[64]; +#ifdef DCPOMATIC_WINDOWS + __mingw_snprintf (buffer, sizeof(buffer), "[CONT %" PRId64 " %fs]", t.get(), t.seconds()); +#else + snprintf (buffer, sizeof(buffer), "[CONT %" PRId64 " %fs]", t.get(), t.seconds()); +#endif + return buffer; } -ostream & -operator<< (ostream& s, DCPTime t) +string +dcpomatic::to_string (DCPTime t) { - s << "[DCP " << t.get() << " " << t.seconds() << "s]"; - return s; + char buffer[64]; +#ifdef DCPOMATIC_WINDOWS + __mingw_snprintf (buffer, sizeof(buffer), "[DCP %" PRId64 " %fs]", t.get(), t.seconds()); +#else + snprintf (buffer, sizeof(buffer), "[DCP %" PRId64 " %fs]", t.get(), t.seconds()); +#endif + return buffer; } -ostream & -operator<< (ostream& s, DCPTimePeriod p) +string +dcpomatic::to_string (DCPTimePeriod p) { - s << "[DCP " << p.from.get() << " " << p.from.seconds() << "s -> " << p.to.get() << " " << p.to.seconds() << "s]"; - return s; + char buffer[64]; +#ifdef DCPOMATIC_WINDOWS + __mingw_snprintf (buffer, sizeof(buffer), "[DCP %" PRId64 " %fs -> %" PRId64 " %fs]", p.from.get(), p.from.seconds(), p.to.get(), p.to.seconds()); +#else + snprintf (buffer, sizeof(buffer), "[DCP %" PRId64 " %fs -> %" PRId64 " %fs]", p.from.get(), p.from.seconds(), p.to.get(), p.to.seconds()); +#endif + return buffer; }