From 6f125b65d1bc0650735624d7ada17a2ff573cbc4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 23 Dec 2014 22:29:44 +0000 Subject: Some missed bits from 0.x. --- src/dcp_time.cc | 22 ++++++---------------- src/dcp_time.h | 1 + src/subtitle_content.cc | 4 ++-- src/subtitle_content.h | 2 +- 4 files changed, 10 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/dcp_time.cc b/src/dcp_time.cc index 9ce36764..4033e5dd 100644 --- a/src/dcp_time.cc +++ b/src/dcp_time.cc @@ -99,23 +99,13 @@ dcp::operator!= (Time const & a, Time const & b) bool dcp::operator<= (Time const & a, Time 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; - } - - if (a.t != b.t) { - return a.t <= b.t; - } + return a < b || a == b; +} - return true; +bool +dcp::operator>= (Time const & a, Time const & b) +{ + return a > b || a == b; } bool diff --git a/src/dcp_time.h b/src/dcp_time.h index 027cb9d2..70bc5573 100644 --- a/src/dcp_time.h +++ b/src/dcp_time.h @@ -79,6 +79,7 @@ extern bool operator!= (Time const & a, Time const & b); extern bool operator<= (Time const & a, Time const & b); extern bool operator< (Time const & a, Time const & b); extern bool operator> (Time const & a, Time const & b); +extern bool operator>= (Time const & a, Time const & b); extern std::ostream & operator<< (std::ostream & s, Time const & t); extern Time operator+ (Time a, Time const & b); extern Time operator- (Time a, Time const & b); diff --git a/src/subtitle_content.cc b/src/subtitle_content.cc index b074afa8..592bfc62 100644 --- a/src/subtitle_content.cc +++ b/src/subtitle_content.cc @@ -148,11 +148,11 @@ SubtitleContent::maybe_add_subtitle (string text, ParseState const & parse_state } list -SubtitleContent::subtitles_at (Time t) const +SubtitleContent::subtitles_during (Time from, Time to) const { list s; for (list::const_iterator i = _subtitles.begin(); i != _subtitles.end(); ++i) { - if (i->in() <= t && t <= i->out ()) { + if (i->out() >= from && i->in() <= to) { s.push_back (*i); } } diff --git a/src/subtitle_content.h b/src/subtitle_content.h index 349a69c8..94b46868 100644 --- a/src/subtitle_content.h +++ b/src/subtitle_content.h @@ -52,7 +52,7 @@ public: return _language; } - std::list subtitles_at (Time t) const; + std::list subtitles_during (Time from, Time to) const; std::list const & subtitles () const { return _subtitles; } -- cgit v1.2.3