23 #include "qgis_core.h" 63 T
lower()
const {
return mLower; }
70 T
upper()
const {
return mUpper; }
93 bool isEmpty()
const {
return mLower > mUpper || ( mUpper == mLower && !( mIncludeLower || mIncludeUpper ) ); }
99 bool isSingleton()
const {
return mLower == mUpper && ( mIncludeLower || mIncludeUpper ); }
107 bool lowerOk = ( mIncludeLower && mLower <= other.mLower )
108 || ( !mIncludeLower && mLower < other.mLower )
109 || ( !mIncludeLower && !other.mIncludeLower && mLower <= other.mLower );
113 bool upperOk = ( mIncludeUpper && mUpper >= other.mUpper )
114 || ( !mIncludeUpper && mUpper > other.mUpper )
115 || ( !mIncludeUpper && !other.mIncludeUpper && mUpper >= other.mUpper );
127 bool lowerOk = ( mIncludeLower && mLower <= element )
128 || ( !mIncludeLower && mLower < element );
132 bool upperOk = ( mIncludeUpper && mUpper >= element )
133 || ( !mIncludeUpper && mUpper > element );
146 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
147 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
150 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
151 && ( ( mIncludeUpper && mUpper >= other.mLower ) || ( !mIncludeUpper && mUpper > other.mLower ) ) )
154 if ( ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) )
155 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
158 if ( ( ( mIncludeLower && mLower >= other.mLower ) || ( !mIncludeLower && mLower > other.mLower ) )
159 && ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) ) )
162 if ( mLower == other.mLower && mUpper == other.mUpper )
173 bool mIncludeLower =
true;
174 bool mIncludeUpper =
true;
217 template <
typename T>
228 QgsTemporalRange(
const T &begin = T(),
const T &end = T(),
bool includeBeginning =
true,
bool includeEnd =
true )
231 , mIncludeLower( includeBeginning )
232 , mIncludeUpper( includeEnd )
235 QgsTemporalRange(
const T &begin,
const T &end,
bool includeBeginning =
true,
bool includeEnd =
true );
251 T
end()
const {
return mUpper; }
273 bool isInstant()
const {
return mLower.isValid() && mUpper.isValid() && mLower == mUpper && ( mIncludeLower || mIncludeUpper ); }
282 return !mLower.isValid() && !mUpper.isValid();
292 if ( !mLower.isValid() && !mUpper.isValid() )
295 if ( mLower.isValid() != mUpper.isValid() )
298 if ( mLower > mUpper )
301 if ( mLower == mUpper && !( mIncludeLower || mIncludeUpper ) )
312 if ( !other.mLower.isValid() && mLower.isValid() )
315 if ( mLower.isValid() )
317 bool lowerOk = ( mIncludeLower && mLower <= other.mLower )
318 || ( !mIncludeLower && mLower < other.mLower )
319 || ( !mIncludeLower && !other.mIncludeLower && mLower <= other.mLower );
324 if ( !other.mUpper.isValid() && mUpper.isValid() )
327 if ( mUpper.isValid() )
329 bool upperOk = ( mIncludeUpper && mUpper >= other.mUpper )
330 || ( !mIncludeUpper && mUpper > other.mUpper )
331 || ( !mIncludeUpper && !other.mIncludeUpper && mUpper >= other.mUpper );
344 if ( !element.isValid() )
347 if ( mLower.isValid() )
349 bool lowerOk = ( mIncludeLower && mLower <= element )
350 || ( !mIncludeLower && mLower < element );
355 if ( mUpper.isValid() )
357 bool upperOk = ( mIncludeUpper && mUpper >= element )
358 || ( !mIncludeUpper && mUpper > element );
371 if ( !mUpper.isValid() && ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) ) )
374 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
375 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
378 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
379 && ( ( mIncludeUpper && mUpper >= other.mLower ) || ( !mIncludeUpper && mUpper > other.mLower ) ) )
382 if ( ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) )
383 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
386 if ( ( ( mIncludeLower && mLower >= other.mLower ) || ( !mIncludeLower && mLower > other.mLower ) )
387 && ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) ) )
390 if ( mLower == other.mLower && mUpper == other.mUpper )
398 return mLower == other.mLower &&
399 mUpper == other.mUpper &&
400 mIncludeLower == other.mIncludeLower &&
401 mIncludeUpper == other.mIncludeUpper;
408 bool mIncludeLower =
true;
409 bool mIncludeUpper =
true;
bool isInfinite() const
Returns true if the range consists of all possible values.
bool contains(const QgsRange< T > &other) const
Returns true if this range contains another range.
bool overlaps(const QgsRange< T > &other) const
Returns true if this range overlaps another range.
A template based class for storing temporal ranges (beginning to end values).
bool includeLower() const
Returns true if the lower bound is inclusive, or false if the lower bound is exclusive.
bool contains(T element) const
Returns true if this range contains a specified element.
QgsTemporalRange(const T &begin=T(), const T &end=T(), bool includeBeginning=true, bool includeEnd=true)
Constructor for QgsTemporalRange.
T upper() const
Returns the upper bound of the range.
T begin() const
Returns the beginning of the range.
T end() const
Returns the upper bound of the range.
QgsRange< double > QgsDoubleRange
QgsRange which stores a range of double values.
bool includeUpper() const
Returns true if the upper bound is inclusive, or false if the upper bound is exclusive.
bool includeEnd() const
Returns true if the end is inclusive, or false if the end is exclusive.
bool operator==(const QgsTemporalRange< T > &other) const
bool isInstant() const
Returns true if the range consists only of a single instant.
bool isSingleton() const
Returns true if the range consists only of a single value or instant.
QgsTemporalRange< QDate > QgsDateRange SIP_DOC_TEMPLATE
QgsRange which stores a range of dates.
bool overlaps(const QgsTemporalRange< T > &other) const
Returns true if this range overlaps another range.
bool isEmpty() const
Returns true if the range is empty, ie the lower bound equals (or exceeds) the upper bound and either...
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 includeBeginning() const
Returns true if the beginning is inclusive, or false if the beginning is exclusive.
bool contains(const T &element) const
Returns true if this range contains a specified element.
bool contains(const QgsTemporalRange< T > &other) const
Returns true if this range contains another range.
bool isEmpty() const
Returns true if the range is empty, ie the beginning equals (or exceeds) the end and either of the bo...
T lower() const
Returns the lower bound of the range.