29using namespace Qt::StringLiterals;
70 ,
mIncludeLower( limits ==
Qgis::RangeLimits::IncludeLowerExcludeUpper || limits ==
Qgis::RangeLimits::IncludeBoth )
71 ,
mIncludeUpper( limits ==
Qgis::RangeLimits::ExcludeLowerIncludeUpper || limits ==
Qgis::RangeLimits::IncludeBoth )
248 QgsDoubleRange(
double lower,
double upper,
bool includeLower =
true,
bool includeUpper =
true )
249 :
QgsRange( lower, upper, includeLower, includeUpper )
258 : QgsRange( std::numeric_limits< double >::lowest(), std::numeric_limits< double >::max(), true, true )
266 bool isInfinite()
const {
return lower() == std::numeric_limits< double >::lowest() &&
upper() == std::numeric_limits< double >::max(); }
270 SIP_PYOBJECT __repr__();
272 QString str = u
"<QgsDoubleRange: %1%2, %3%4>"_s.arg( sipCpp->includeLower() ? u
"["_s : u
"("_s )
273 .arg( sipCpp->lower() )
274 .arg( sipCpp->upper() )
275 .arg( sipCpp->includeUpper() ? u
"]"_s : u
")"_s );
276 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
331 QgsIntRange(
int lower,
int upper,
bool includeLower =
true,
bool includeUpper =
true )
332 :
QgsRange( lower, upper, includeLower, includeUpper )
341 :
QgsRange( std::numeric_limits< int >::lowest(), std::numeric_limits< int >::max(), true, true )
349 bool isInfinite()
const {
return lower() == std::numeric_limits< int >::lowest() &&
upper() == std::numeric_limits< int >::max(); }
353 SIP_PYOBJECT __repr__();
355 QString str = u
"<QgsIntRange: %1%2, %3%4>"_s.arg( sipCpp->includeLower() ? u
"["_s : u
"("_s )
356 .arg( sipCpp->lower() )
357 .arg( sipCpp->upper() )
358 .arg( sipCpp->includeUpper() ? u
"]"_s : u
")"_s );
359 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
399 QgsTemporalRange(
const T &begin,
const T &end,
bool includeBeginning =
true,
bool includeEnd =
true );
415 T
end()
const {
return mUpper; }
437 bool isInstant()
const {
return mLower.isValid() && mUpper.isValid() && mLower == mUpper && ( mIncludeLower || mIncludeUpper ); }
444 bool isInfinite()
const {
return !mLower.isValid() && !mUpper.isValid(); }
453 if ( !mLower.isValid() && !mUpper.isValid() )
456 if ( mLower.isValid() != mUpper.isValid() )
459 if ( mLower > mUpper )
462 if ( mLower == mUpper && !( mIncludeLower || mIncludeUpper ) )
473 if ( !other.mLower.isValid() && mLower.isValid() )
476 if ( mLower.isValid() )
478 const bool lowerOk = ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) || ( !mIncludeLower && !other.mIncludeLower && mLower <= other.mLower );
483 if ( !other.mUpper.isValid() && mUpper.isValid() )
486 if ( mUpper.isValid() )
488 const bool upperOk = ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) || ( !mIncludeUpper && !other.mIncludeUpper && mUpper >= other.mUpper );
501 if ( !element.isValid() )
504 if ( mLower.isValid() )
506 const bool lowerOk = ( mIncludeLower && mLower <= element ) || ( !mIncludeLower && mLower < element );
511 if ( mUpper.isValid() )
513 const bool upperOk = ( mIncludeUpper && mUpper >= element ) || ( !mIncludeUpper && mUpper > element );
532 if ( mLower.isValid() && mUpper.isValid() && other.mLower.isValid() && other.mUpper.isValid() )
535 if ( other.mUpper < mLower || other.mLower > mUpper )
539 if ( other.mUpper > mLower && other.mLower < mUpper )
544 if ( other.mUpper == mLower && mLower.isValid() )
545 return other.mIncludeUpper && mIncludeLower;
548 if ( other.mLower == mUpper && mUpper.isValid() )
549 return other.mIncludeLower && mIncludeUpper;
551 if ( !mLower.isValid() )
552 return other.mLower < mUpper || !other.mLower.isValid();
554 if ( !mUpper.isValid() )
555 return other.mUpper > mLower || !other.mUpper.isValid();
557 if ( !other.mLower.isValid() )
558 return other.mUpper > mLower || !mLower.isValid();
560 if ( !other.mUpper.isValid() )
561 return other.mLower < mUpper || !mUpper.isValid();
583 mLower = other.
begin();
584 mUpper = other.
end();
591 bool changed {
false };
594 if ( !other.
begin().isValid() || (
begin().isValid() && other.
begin() < mLower ) )
596 mLower = other.
begin();
602 mIncludeLower =
true;
607 if ( !other.
end().isValid() || (
end().isValid() && other.
end() > mUpper ) )
609 mUpper = other.
end();
613 else if ( other.
end() == mUpper && other.
includeEnd() && !mIncludeUpper )
615 mIncludeUpper =
true;
638 if ( ranges.empty() )
641 QList< QgsTemporalRange<T > > sortedRanges = ranges;
644 QList< QgsTemporalRange<T>> res;
645 res.reserve( sortedRanges.size() );
648 auto it = sortedRanges.constBegin();
650 for ( ; it != sortedRanges.constEnd(); ++it )
669 return mLower == other.mLower && mUpper == other.mUpper && mIncludeLower == other.
includeBeginning() && mIncludeUpper == other.
includeEnd();
677 bool mIncludeLower =
true;
678 bool mIncludeUpper =
true;
Provides global constants and enumerations for use throughout the application.
RangeLimits
Describes how the limits of a range are handled.
@ ExcludeLowerIncludeUpper
Lower value is excluded from the range, upper value in inccluded.
@ IncludeBoth
Both lower and upper values are included in the range.
@ ExcludeBoth
Both lower and upper values are excluded from the range.
@ IncludeLowerExcludeUpper
Lower value is included in the range, upper value is excluded.
QgsRange which stores a range of double values.
QgsDoubleRange(double lower, double upper, Qgis::RangeLimits limits)
Constructor for QgsDoubleRange.
QgsDoubleRange(double lower=std::numeric_limits< double >::lowest(), double upper=std::numeric_limits< double >::max(), bool includeLower=true, bool includeUpper=true)
Constructor for QgsDoubleRange.
bool operator==(const QgsDoubleRange &other) const
bool isInfinite() const
Returns true if the range consists of all possible values.
bool operator!=(const QgsDoubleRange &other) const
QgsRange which stores a range of integer values.
bool isInfinite() const
Returns true if the range consists of all possible values.
QgsIntRange(int lower, int upper, Qgis::RangeLimits limits)
Constructor for QgsIntRange.
QgsIntRange(int lower=std::numeric_limits< int >::lowest(), int upper=std::numeric_limits< int >::max(), bool includeLower=true, bool includeUpper=true)
Constructor for QgsIntRange.
A template based class for storing ranges (lower to upper values).
QgsRange(T lower, T upper, Qgis::RangeLimits limits)
Constructor for QgsRange.
bool includeUpper() const
bool overlaps(const QgsRange< T > &other) const
Returns true if this range overlaps another range.
Qgis::RangeLimits rangeLimits() const
Returns the limit handling of the range.
QgsRange(T lower, T upper, bool includeLower=true, bool includeUpper=true)
Constructor for QgsRange.
bool contains(const QgsRange< T > &other) const
Returns true if this range contains another range.
bool includeLower() const
bool isSingleton() const
Returns true if the range consists only of a single value or instant.
bool operator!=(const QgsRange< T > &other) const
bool contains(T element) const
Returns true if this range contains a specified element.
bool operator==(const QgsRange< T > &other) const
bool isEmpty() const
Returns true if the range is empty, ie the lower bound equals (or exceeds) the upper bound and either...
A template based class for storing temporal ranges (beginning to end values).
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 extend(const QgsTemporalRange< T > &other)
Extends the range in place by extending this range out to include an other range.
bool isInstant() const
Returns true if the range consists only of a single instant.
bool operator!=(const QgsTemporalRange< T > &other) const
QgsTemporalRange(const T &begin=T(), const T &end=T(), bool includeBeginning=true, bool includeEnd=true)
Constructor for QgsTemporalRange.
bool operator==(const QgsTemporalRange< T > &other) const
bool overlaps(const QgsTemporalRange< T > &other) const
Returns true if this range overlaps another range.
bool includeBeginning() const
bool isEmpty() const
Returns true if the range is empty, ie the beginning equals (or exceeds) the end and either of the bo...
static QList< QgsTemporalRange< T > > mergeRanges(const QList< QgsTemporalRange< T > > &ranges)
Merges a list of temporal ranges.
bool isInfinite() const
Returns true if the range consists of all possible values.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference).
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QgsTemporalRange< QDate > QgsDateRange
QgsRange which stores a range of dates.
QgsTemporalRange< QDateTime > QgsDateTimeRange
QgsRange which stores a range of date times.
QgsRange< double > QgsRangedoubleBase
QgsRange< int > QgsRangeintBase