From 9936ec84cb2a5e5f8f4fe77bcd5742f06bdb2d6c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 20 Dec 2023 23:41:35 +0100 Subject: Add operator<= for HMSF. --- src/lib/dcpomatic_time.cc | 19 +++++++++++++++++++ src/lib/dcpomatic_time.h | 3 +++ 2 files changed, 22 insertions(+) (limited to 'src/lib') diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index ac797f8f4..60fc5342a 100644 --- a/src/lib/dcpomatic_time.cc +++ b/src/lib/dcpomatic_time.cc @@ -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::Time (DCPTime d, FrameRateChange f) : _t (llrint(d.get() * f.speed_up)) diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index 9ebb334fe..63bb86549 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -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 -- cgit v1.2.3