diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-12-23 22:29:44 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-12-23 22:29:44 +0000 |
| commit | 6f125b65d1bc0650735624d7ada17a2ff573cbc4 (patch) | |
| tree | c37d69892f5d0fe244991f66110243caa030de8d /src | |
| parent | 2e25fdc885226110c0ab28b3c8026e3dc4345cb5 (diff) | |
Some missed bits from 0.x.
Diffstat (limited to 'src')
| -rw-r--r-- | src/dcp_time.cc | 22 | ||||
| -rw-r--r-- | src/dcp_time.h | 1 | ||||
| -rw-r--r-- | src/subtitle_content.cc | 4 | ||||
| -rw-r--r-- | src/subtitle_content.h | 2 |
4 files changed, 10 insertions, 19 deletions
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<SubtitleString> -SubtitleContent::subtitles_at (Time t) const +SubtitleContent::subtitles_during (Time from, Time to) const { list<SubtitleString> s; for (list<SubtitleString>::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<SubtitleString> subtitles_at (Time t) const; + std::list<SubtitleString> subtitles_during (Time from, Time to) const; std::list<SubtitleString> const & subtitles () const { return _subtitles; } |
