22 #include "qgis_core.h" 65 T
lower()
const {
return mLower; }
72 T
upper()
const {
return mUpper; }
95 bool isEmpty()
const {
return mLower > mUpper || ( mUpper == mLower && !( mIncludeLower || mIncludeUpper ) ); }
101 bool isSingleton()
const {
return mLower == mUpper && ( mIncludeLower || mIncludeUpper ); }
109 bool lowerOk = ( mIncludeLower && mLower <= other.mLower )
110 || ( !mIncludeLower && mLower < other.mLower )
111 || ( !mIncludeLower && !other.mIncludeLower && mLower <= other.mLower );
115 bool upperOk = ( mIncludeUpper && mUpper >= other.mUpper )
116 || ( !mIncludeUpper && mUpper > other.mUpper )
117 || ( !mIncludeUpper && !other.mIncludeUpper && mUpper >= other.mUpper );
129 bool lowerOk = ( mIncludeLower && mLower <= element )
130 || ( !mIncludeLower && mLower < element );
134 bool upperOk = ( mIncludeUpper && mUpper >= element )
135 || ( !mIncludeUpper && mUpper > element );
148 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
149 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
152 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
153 && ( ( mIncludeUpper && mUpper >= other.mLower ) || ( !mIncludeUpper && mUpper > other.mLower ) ) )
156 if ( ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) )
157 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
160 if ( ( ( mIncludeLower && mLower >= other.mLower ) || ( !mIncludeLower && mLower > other.mLower ) )
161 && ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) ) )
164 if ( mLower == other.mLower && mUpper == other.mUpper )
174 bool mIncludeLower =
true;
175 bool mIncludeUpper =
true;
218 template <
typename T>
229 QgsTemporalRange(
const T &begin = T(),
const T &end = T(),
bool includeBeginning =
true,
bool includeEnd =
true )
232 , mIncludeLower( includeBeginning )
233 , mIncludeUpper( includeEnd )
236 QgsTemporalRange(
const T &begin,
const T &end,
bool includeBeginning =
true,
bool includeEnd =
true );
252 T
end()
const {
return mUpper; }
274 bool isInstant()
const {
return mLower.isValid() && mUpper.isValid() && mLower == mUpper && ( mIncludeLower || mIncludeUpper ); }
283 return !mLower.isValid() && !mUpper.isValid();
293 if ( !mLower.isValid() && !mUpper.isValid() )
296 if ( mLower.isValid() != mUpper.isValid() )
299 if ( mLower > mUpper )
302 if ( mLower == mUpper && !( mIncludeLower || mIncludeUpper ) )
313 if ( !other.mLower.isValid() && mLower.isValid() )
316 if ( mLower.isValid() )
318 bool lowerOk = ( mIncludeLower && mLower <= other.mLower )
319 || ( !mIncludeLower && mLower < other.mLower )
320 || ( !mIncludeLower && !other.mIncludeLower && mLower <= other.mLower );
325 if ( !other.mUpper.isValid() && mUpper.isValid() )
328 if ( mUpper.isValid() )
330 bool upperOk = ( mIncludeUpper && mUpper >= other.mUpper )
331 || ( !mIncludeUpper && mUpper > other.mUpper )
332 || ( !mIncludeUpper && !other.mIncludeUpper && mUpper >= other.mUpper );
345 if ( !element.isValid() )
348 if ( mLower.isValid() )
350 bool lowerOk = ( mIncludeLower && mLower <= element )
351 || ( !mIncludeLower && mLower < element );
356 if ( mUpper.isValid() )
358 bool upperOk = ( mIncludeUpper && mUpper >= element )
359 || ( !mIncludeUpper && mUpper > element );
372 if ( !mUpper.isValid() && ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) ) )
375 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
376 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
379 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
380 && ( ( mIncludeUpper && mUpper >= other.mLower ) || ( !mIncludeUpper && mUpper > other.mLower ) ) )
383 if ( ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) )
384 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
387 if ( ( ( mIncludeLower && mLower >= other.mLower ) || ( !mIncludeLower && mLower > other.mLower ) )
388 && ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) ) )
391 if ( mLower == other.mLower && mUpper == other.mUpper )
413 mLower = other.
begin();
414 mUpper = other.
end();
421 bool changed {
false };
424 if ( ! other.
begin().isValid()
425 || ( begin().isValid() && other.
begin() < mLower ) )
427 mLower = other.
begin();
433 mIncludeLower =
true;
438 if ( ! other.
end().isValid()
439 || ( end().isValid() && other.
end() > mUpper ) )
441 mUpper = other.
end();
445 else if ( other.
end() == mUpper && other.
includeEnd() && ! mIncludeUpper )
447 mIncludeUpper =
true;
455 return mLower == other.mLower &&
456 mUpper == other.mUpper &&
465 bool mIncludeLower =
true;
466 bool mIncludeUpper =
true;
bool contains(const QgsTemporalRange< T > &other) const
Returns true if this range contains another range.
bool includeEnd() const
Returns true if the end is inclusive, or false if the end is exclusive.
bool isInfinite() const
Returns true if the range consists of all possible values.
A template based class for storing temporal ranges (beginning to end values).
bool overlaps(const QgsRange< T > &other) const
Returns true if this range overlaps another range.
bool extend(const QgsTemporalRange< T > &other)
Extends the range in place by extending this range out to include an other range. ...
T lower() const
Returns the lower bound of the range.
QgsTemporalRange(const T &begin=T(), const T &end=T(), bool includeBeginning=true, bool includeEnd=true)
Constructor for QgsTemporalRange.
bool isEmpty() const
Returns true if the range is empty, ie the lower bound equals (or exceeds) the upper bound and either...
bool contains(const T &element) const
Returns true if this range contains a specified element.
T begin() const
Returns the beginning of the range.
bool isEmpty() const
Returns true if the range is empty, ie the beginning equals (or exceeds) the end and either of the bo...
QgsRange< double > QgsDoubleRange
QgsRange which stores a range of double values.
bool isSingleton() const
Returns true if the range consists only of a single value or instant.
bool contains(const QgsRange< T > &other) const
Returns true if this range contains another range.
bool isInstant() const
Returns true if the range consists only of a single instant.
bool operator==(const QgsTemporalRange< T > &other) const
bool overlaps(const QgsTemporalRange< T > &other) const
Returns true if this range overlaps another range.
bool includeUpper() const
Returns true if the upper bound is inclusive, or false if the upper bound is exclusive.
bool includeBeginning() const
Returns true if the beginning is inclusive, or false if the beginning is exclusive.
bool includeLower() const
Returns true if the lower bound is inclusive, or false if the lower bound is exclusive.
QgsTemporalRange< QDate > QgsDateRange SIP_DOC_TEMPLATE
QgsRange which stores a range of dates.
T upper() const
Returns the upper bound of the range.
QgsRange(T lower, T upper, bool includeLower=true, bool includeUpper=true)
Constructor for QgsRange.
A template based class for storing ranges (lower to upper values).
QgsRange< int > QgsIntRange
QgsRange which stores a range of integer values.
bool contains(T element) const
Returns true if this range contains a specified element.
T end() const
Returns the upper bound of the range.