29using namespace Qt::StringLiterals;
72 ,
mIncludeLower( limits ==
Qgis::RangeLimits::IncludeLowerExcludeUpper || limits ==
Qgis::RangeLimits::IncludeBoth )
73 ,
mIncludeUpper( limits ==
Qgis::RangeLimits::ExcludeLowerIncludeUpper || limits ==
Qgis::RangeLimits::IncludeBoth )
209 return ( !
operator==( other ) );
260 double upper = std::numeric_limits< double >::max(),
272 bool includeLower =
true,
bool includeUpper =
true )
273 :
QgsRange( lower, upper, includeLower, includeUpper )
282 : QgsRange( std::numeric_limits< double >::lowest(), std::numeric_limits< double >::max(), true, true )
292 return lower() == std::numeric_limits< double >::lowest() &&
upper() == std::numeric_limits< double >::max();
296 SIP_PYOBJECT __repr__();
298 QString str = u
"<QgsDoubleRange: %1%2, %3%4>"_s.arg( sipCpp->includeLower() ? u
"["_s : u
"("_s )
299 .arg( sipCpp->lower() )
300 .arg( sipCpp->upper() )
301 .arg( sipCpp->includeUpper() ? u
"]"_s : u
")"_s );
302 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
316 return ( !
operator==( other ) );
356 int upper = std::numeric_limits< int >::max(),
368 bool includeLower =
true,
bool includeUpper =
true )
369 :
QgsRange( lower, upper, includeLower, includeUpper )
378 :
QgsRange( std::numeric_limits< int >::lowest(), std::numeric_limits< int >::max(), true, true )
388 return lower() == std::numeric_limits< int >::lowest() &&
upper() == std::numeric_limits< int >::max();
392 SIP_PYOBJECT __repr__();
394 QString str = u
"<QgsIntRange: %1%2, %3%4>"_s.arg( sipCpp->includeLower() ? u
"["_s : u
"("_s )
395 .arg( sipCpp->lower() )
396 .arg( sipCpp->upper() )
397 .arg( sipCpp->includeUpper() ? u
"]"_s : u
")"_s );
398 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
456 T
end()
const {
return mUpper; }
478 bool isInstant()
const {
return mLower.isValid() && mUpper.isValid() && mLower == mUpper && ( mIncludeLower || mIncludeUpper ); }
487 return !mLower.isValid() && !mUpper.isValid();
497 if ( !mLower.isValid() && !mUpper.isValid() )
500 if ( mLower.isValid() != mUpper.isValid() )
503 if ( mLower > mUpper )
506 if ( mLower == mUpper && !( mIncludeLower || mIncludeUpper ) )
517 if ( !other.mLower.isValid() && mLower.isValid() )
520 if ( mLower.isValid() )
522 const bool lowerOk = ( mIncludeLower && mLower <= other.mLower )
523 || ( !mIncludeLower && mLower < other.mLower )
524 || ( !mIncludeLower && !other.mIncludeLower && mLower <= other.mLower );
529 if ( !other.mUpper.isValid() && mUpper.isValid() )
532 if ( mUpper.isValid() )
534 const bool upperOk = ( mIncludeUpper && mUpper >= other.mUpper )
535 || ( !mIncludeUpper && mUpper > other.mUpper )
536 || ( !mIncludeUpper && !other.mIncludeUpper && mUpper >= other.mUpper );
549 if ( !element.isValid() )
552 if ( mLower.isValid() )
554 const bool lowerOk = ( mIncludeLower && mLower <= element )
555 || ( !mIncludeLower && mLower < element );
560 if ( mUpper.isValid() )
562 const bool upperOk = ( mIncludeUpper && mUpper >= element )
563 || ( !mIncludeUpper && mUpper > element );
582 if ( mLower.isValid() && mUpper.isValid() && other.mLower.isValid() && other.mUpper.isValid() )
585 if ( other.mUpper < mLower || other.mLower > mUpper )
589 if ( other.mUpper > mLower && other.mLower < mUpper )
594 if ( other.mUpper == mLower && mLower.isValid() )
595 return other.mIncludeUpper && mIncludeLower;
598 if ( other.mLower == mUpper && mUpper.isValid() )
599 return other.mIncludeLower && mIncludeUpper;
601 if ( !mLower.isValid() )
602 return other.mLower < mUpper || !other.mLower.isValid();
604 if ( !mUpper.isValid() )
605 return other.mUpper > mLower || !other.mUpper.isValid();
607 if ( !other.mLower.isValid() )
608 return other.mUpper > mLower || !mLower.isValid();
610 if ( !other.mUpper.isValid() )
611 return other.mLower < mUpper || !mUpper.isValid();
633 mLower = other.
begin();
634 mUpper = other.
end();
641 bool changed {
false };
644 if ( ! other.
begin().isValid()
645 || (
begin().isValid() && other.
begin() < mLower ) )
647 mLower = other.
begin();
653 mIncludeLower =
true;
658 if ( ! other.
end().isValid()
659 || (
end().isValid() && other.
end() > mUpper ) )
661 mUpper = other.
end();
665 else if ( other.
end() == mUpper && other.
includeEnd() && ! mIncludeUpper )
667 mIncludeUpper =
true;
690 if ( ranges.empty() )
693 QList< QgsTemporalRange<T > > sortedRanges = ranges;
696 QList< QgsTemporalRange<T>> res;
697 res.reserve( sortedRanges.size() );
700 auto it = sortedRanges.constBegin();
702 for ( ; it != sortedRanges.constEnd(); ++it )
721 return mLower == other.mLower &&
722 mUpper == other.mUpper &&
729 return ( !
operator==( other ) );
736 bool mIncludeLower =
true;
737 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...
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