Add operator<= for HMSF.
authorCarl Hetherington <cth@carlh.net>
Wed, 20 Dec 2023 22:41:35 +0000 (23:41 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 12 Mar 2024 22:41:00 +0000 (23:41 +0100)
src/lib/dcpomatic_time.cc
src/lib/dcpomatic_time.h

index ac797f8f4205589c5ad605dc768deb83bbfed54e..60fc5342a33437414fec6f1b76ad38086320324c 100644 (file)
@@ -27,6 +27,25 @@ using std::string;
 using namespace dcpomatic;
 
 
+bool
+dcpomatic::operator<=(HMSF const& a, HMSF const& b)
+{
+       if (a.h != b.h) {
+               return a.h <= b.h;
+       }
+
+       if (a.m != b.m) {
+               return a.m <= b.m;
+       }
+
+       if (a.s != b.s) {
+               return a.s <= b.s;
+       }
+
+       return a.f <= b.f;
+}
+
+
 template <>
 Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time (DCPTime d, FrameRateChange f)
        : _t (llrint(d.get() * f.speed_up))
index 9ebb334fe118e284e9cb609d53b75e3e29b4cf3a..63bb865491f32cecc957c2181e550492fbdd8b29 100644 (file)
@@ -64,6 +64,9 @@ public:
 };
 
 
+bool operator<=(HMSF const& a, HMSF const& b);
+
+
 /** A time in seconds, expressed as a number scaled up by Time::HZ.  We want two different
  *  versions of this class, dcpomatic::ContentTime and dcpomatic::DCPTime, and we want it to be impossible to
  *  convert implicitly between the two.  Hence there's this template hack.  I'm not