69 ,
mIncludeLower( limits ==
Qgis::RangeLimits::IncludeLowerExcludeUpper || limits ==
Qgis::RangeLimits::IncludeBoth )
70 ,
mIncludeUpper( limits ==
Qgis::RangeLimits::ExcludeLowerIncludeUpper || limits ==
Qgis::RangeLimits::IncludeBoth )
206 return ( !
operator==( other ) );
257 double upper = std::numeric_limits< double >::max(),
258 bool includeLower =
true,
bool includeUpper =
true )
259 :
QgsRange( lower, upper, includeLower, includeUpper )
269 bool includeLower =
true,
bool includeUpper =
true )
270 :
QgsRange( lower, upper, includeLower, includeUpper )
279 :
QgsRange( std::numeric_limits< double >::lowest(), std::numeric_limits< double >::max(), true, true )
289 return lower() == std::numeric_limits< double >::lowest() &&
upper() == std::numeric_limits< double >::max();
293 SIP_PYOBJECT __repr__();
295 QString str = QStringLiteral(
"<QgsDoubleRange: %1%2, %3%4>" ).arg( sipCpp->includeLower() ? QStringLiteral(
"[" ) : QStringLiteral(
"(" ) )
296 .arg( sipCpp->lower() )
297 .arg( sipCpp->upper() )
298 .arg( sipCpp->includeUpper() ? QStringLiteral(
"]" ) : QStringLiteral(
")" ) );
299 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
313 return ( !
operator==( other ) );
353 int upper = std::numeric_limits< int >::max(),
354 bool includeLower =
true,
bool includeUpper =
true )
355 :
QgsRange( lower, upper, includeLower, includeUpper )
365 bool includeLower =
true,
bool includeUpper =
true )
366 :
QgsRange( lower, upper, includeLower, includeUpper )
375 :
QgsRange( std::numeric_limits< int >::lowest(), std::numeric_limits< int >::max(), true, true )
385 return lower() == std::numeric_limits< int >::lowest() && upper() == std::numeric_limits< int >::max();
389 SIP_PYOBJECT __repr__();
391 QString str = QStringLiteral(
"<QgsIntRange: %1%2, %3%4>" ).arg( sipCpp->includeLower() ? QStringLiteral(
"[" ) : QStringLiteral(
"(" ) )
392 .arg( sipCpp->lower() )
393 .arg( sipCpp->upper() )
394 .arg( sipCpp->includeUpper() ? QStringLiteral(
"]" ) : QStringLiteral(
")" ) );
395 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
453 T
end()
const {
return mUpper; }
475 bool isInstant()
const {
return mLower.isValid() && mUpper.isValid() && mLower == mUpper && ( mIncludeLower || mIncludeUpper ); }
484 return !mLower.isValid() && !mUpper.isValid();
494 if ( !mLower.isValid() && !mUpper.isValid() )
497 if ( mLower.isValid() != mUpper.isValid() )
500 if ( mLower > mUpper )
503 if ( mLower == mUpper && !( mIncludeLower || mIncludeUpper ) )
514 if ( !other.mLower.isValid() && mLower.isValid() )
517 if ( mLower.isValid() )
519 const bool lowerOk = ( mIncludeLower && mLower <= other.mLower )
520 || ( !mIncludeLower && mLower < other.mLower )
521 || ( !mIncludeLower && !other.mIncludeLower && mLower <= other.mLower );
526 if ( !other.mUpper.isValid() && mUpper.isValid() )
529 if ( mUpper.isValid() )
531 const bool upperOk = ( mIncludeUpper && mUpper >= other.mUpper )
532 || ( !mIncludeUpper && mUpper > other.mUpper )
533 || ( !mIncludeUpper && !other.mIncludeUpper && mUpper >= other.mUpper );
546 if ( !element.isValid() )
549 if ( mLower.isValid() )
551 const bool lowerOk = ( mIncludeLower && mLower <= element )
552 || ( !mIncludeLower && mLower < element );
557 if ( mUpper.isValid() )
559 const bool upperOk = ( mIncludeUpper && mUpper >= element )
560 || ( !mIncludeUpper && mUpper > element );
579 if ( mLower.isValid() && mUpper.isValid() && other.mLower.isValid() && other.mUpper.isValid() )
582 if ( other.mUpper < mLower || other.mLower > mUpper )
586 if ( other.mUpper > mLower && other.mLower < mUpper )
591 if ( other.mUpper == mLower && mLower.isValid() )
592 return other.mIncludeUpper && mIncludeLower;
595 if ( other.mLower == mUpper && mUpper.isValid() )
596 return other.mIncludeLower && mIncludeUpper;
598 if ( !mLower.isValid() )
599 return other.mLower < mUpper || !other.mLower.isValid();
601 if ( !mUpper.isValid() )
602 return other.mUpper > mLower || !other.mUpper.isValid();
604 if ( !other.mLower.isValid() )
605 return other.mUpper > mLower || !mLower.isValid();
607 if ( !other.mUpper.isValid() )
608 return other.mLower < mUpper || !mUpper.isValid();
630 mLower = other.
begin();
631 mUpper = other.
end();
638 bool changed {
false };
641 if ( ! other.
begin().isValid()
642 || (
begin().isValid() && other.
begin() < mLower ) )
644 mLower = other.
begin();
650 mIncludeLower =
true;
655 if ( ! other.
end().isValid()
656 || (
end().isValid() && other.
end() > mUpper ) )
658 mUpper = other.
end();
662 else if ( other.
end() == mUpper && other.
includeEnd() && ! mIncludeUpper )
664 mIncludeUpper =
true;
687 if ( ranges.empty() )
690 QList< QgsTemporalRange<T > > sortedRanges = ranges;
693 QList< QgsTemporalRange<T>> res;
694 res.reserve( sortedRanges.size() );
697 auto it = sortedRanges.constBegin();
699 for ( ; it != sortedRanges.constEnd(); ++it )
718 return mLower == other.mLower &&
719 mUpper == other.mUpper &&
726 return ( !
operator==( other ) );
733 bool mIncludeLower =
true;
734 bool mIncludeUpper =
true;
The Qgis class provides global constants 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
Returns true if the upper bound is inclusive, or false if the upper bound is exclusive.
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.
T lower() const
Returns the lower bound of the range.
bool includeLower() const
Returns true if the lower bound is inclusive, or false if the lower bound is exclusive.
T upper() const
Returns the upper bound of the range.
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.
T begin() const
Returns the beginning of the range.
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.
T end() const
Returns the upper bound of the 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 includeEnd() const
Returns true if the end is inclusive, or false if the end is exclusive.
bool includeBeginning() const
Returns true if the beginning is inclusive, or false if the beginning is exclusive.
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.
QgsRange< double > QgsRangedoubleBase
QgsRange< int > QgsRangeintBase