Added convenience functions to TimeRange
This commit is contained in:
parent
c86512f73e
commit
bdfd77bc4a
|
@ -35,6 +35,26 @@ bool TimeRange::empty() const {
|
|||
return start == end;
|
||||
}
|
||||
|
||||
void TimeRange::setStart(time_type newStart) {
|
||||
resize(newStart, end);
|
||||
}
|
||||
|
||||
void TimeRange::setEnd(time_type newEnd) {
|
||||
resize(start, newEnd);
|
||||
}
|
||||
|
||||
void TimeRange::setStartIfEarlier(time_type newStart) {
|
||||
if (newStart < start) {
|
||||
setStart(newStart);
|
||||
}
|
||||
}
|
||||
|
||||
void TimeRange::setEndIfLater(time_type newEnd) {
|
||||
if (newEnd > end) {
|
||||
setEnd(newEnd);
|
||||
}
|
||||
}
|
||||
|
||||
void TimeRange::resize(const TimeRange& newRange) {
|
||||
start = newRange.start;
|
||||
end = newRange.end;
|
||||
|
@ -63,6 +83,14 @@ void TimeRange::trim(const TimeRange& limits) {
|
|||
resize(newRange);
|
||||
}
|
||||
|
||||
void TimeRange::trimLeft(time_type value) {
|
||||
trim({value, end});
|
||||
}
|
||||
|
||||
void TimeRange::trimRight(time_type value) {
|
||||
trim({start, value});
|
||||
}
|
||||
|
||||
bool TimeRange::operator==(const TimeRange& rhs) const {
|
||||
return start == rhs.start && end == rhs.end;
|
||||
}
|
||||
|
|
|
@ -19,12 +19,19 @@ public:
|
|||
time_type getDuration() const;
|
||||
bool empty() const;
|
||||
|
||||
void setStart(time_type newStart);
|
||||
void setEnd(time_type newEnd);
|
||||
void setStartIfEarlier(time_type newStart);
|
||||
void setEndIfLater(time_type newEnd);
|
||||
|
||||
void resize(const TimeRange& newRange);
|
||||
void resize(time_type start, time_type end);
|
||||
void shift(time_type offset);
|
||||
void grow(time_type value);
|
||||
void shrink(time_type value);
|
||||
void trim(const TimeRange& limits);
|
||||
void trimLeft(time_type value);
|
||||
void trimRight(time_type value);
|
||||
|
||||
bool operator==(const TimeRange& rhs) const;
|
||||
bool operator!=(const TimeRange& rhs) const;
|
||||
|
|
Loading…
Reference in New Issue