22 #include "qgis_core.h"
181 return ( !
operator==( other ) );
217 double upper = std::numeric_limits< double >::max(),
218 bool includeLower =
true,
bool includeUpper =
true )
229 bool includeLower =
true,
bool includeUpper =
true )
239 :
QgsRange( std::numeric_limits< double >::lowest(), std::numeric_limits< double >::max(), true, true )
249 return lower() == std::numeric_limits< double >::lowest() &&
upper() == std::numeric_limits< double >::max();
253 SIP_PYOBJECT __repr__();
255 QString
str = QStringLiteral(
"<QgsDoubleRange: %1%2, %3%4>" ).arg( sipCpp->includeLower() ? QStringLiteral(
"[" ) : QStringLiteral(
"(" ) )
256 .arg( sipCpp->lower() )
257 .arg( sipCpp->upper() )
258 .arg( sipCpp->includeUpper() ? QStringLiteral(
"]" ) : QStringLiteral(
")" ) );
259 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
273 return ( !
operator==( other ) );
302 int upper = std::numeric_limits< int >::max(),
303 bool includeLower =
true,
bool includeUpper =
true )
314 bool includeLower =
true,
bool includeUpper =
true )
324 :
QgsRange( std::numeric_limits< int >::lowest(), std::numeric_limits< int >::max(), true, true )
334 return lower() == std::numeric_limits< int >::lowest() &&
upper() == std::numeric_limits< int >::max();
338 SIP_PYOBJECT __repr__();
340 QString
str = QStringLiteral(
"<QgsIntRange: %1%2, %3%4>" ).arg( sipCpp->includeLower() ? QStringLiteral(
"[" ) : QStringLiteral(
"(" ) )
341 .arg( sipCpp->lower() )
342 .arg( sipCpp->upper() )
343 .arg( sipCpp->includeUpper() ? QStringLiteral(
"]" ) : QStringLiteral(
")" ) );
344 sipRes = PyUnicode_FromString(
str.toUtf8().constData() );
367 template <
typename T>
401 T
end()
const {
return mUpper; }
423 bool isInstant()
const {
return mLower.isValid() && mUpper.isValid() && mLower == mUpper && ( mIncludeLower || mIncludeUpper ); }
432 return !mLower.isValid() && !mUpper.isValid();
442 if ( !mLower.isValid() && !mUpper.isValid() )
445 if ( mLower.isValid() != mUpper.isValid() )
448 if ( mLower > mUpper )
451 if ( mLower == mUpper && !( mIncludeLower || mIncludeUpper ) )
462 if ( !other.mLower.isValid() && mLower.isValid() )
465 if ( mLower.isValid() )
467 const bool lowerOk = ( mIncludeLower && mLower <= other.mLower )
468 || ( !mIncludeLower && mLower < other.mLower )
469 || ( !mIncludeLower && !other.mIncludeLower && mLower <= other.mLower );
474 if ( !other.mUpper.isValid() && mUpper.isValid() )
477 if ( mUpper.isValid() )
479 const bool upperOk = ( mIncludeUpper && mUpper >= other.mUpper )
480 || ( !mIncludeUpper && mUpper > other.mUpper )
481 || ( !mIncludeUpper && !other.mIncludeUpper && mUpper >= other.mUpper );
494 if ( !element.isValid() )
497 if ( mLower.isValid() )
499 const bool lowerOk = ( mIncludeLower && mLower <= element )
500 || ( !mIncludeLower && mLower < element );
505 if ( mUpper.isValid() )
507 const bool upperOk = ( mIncludeUpper && mUpper >= element )
508 || ( !mIncludeUpper && mUpper > element );
521 if ( !mUpper.isValid() && ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) ) )
524 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
525 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
528 if ( ( ( mIncludeLower && mLower <= other.mLower ) || ( !mIncludeLower && mLower < other.mLower ) )
529 && ( ( mIncludeUpper && mUpper >= other.mLower ) || ( !mIncludeUpper && mUpper > other.mLower ) ) )
532 if ( ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) )
533 && ( ( mIncludeUpper && mUpper >= other.mUpper ) || ( !mIncludeUpper && mUpper > other.mUpper ) ) )
536 if ( ( ( mIncludeLower && mLower >= other.mLower ) || ( !mIncludeLower && mLower > other.mLower ) )
537 && ( ( mIncludeLower && mLower <= other.mUpper ) || ( !mIncludeLower && mLower < other.mUpper ) ) )
540 if ( mLower == other.mLower && mUpper == other.mUpper )
562 mLower = other.
begin();
563 mUpper = other.
end();
570 bool changed {
false };
573 if ( ! other.
begin().isValid()
574 || (
begin().isValid() && other.
begin() < mLower ) )
576 mLower = other.
begin();
582 mIncludeLower =
true;
587 if ( ! other.
end().isValid()
588 || (
end().isValid() && other.
end() > mUpper ) )
590 mUpper = other.
end();
594 else if ( other.
end() == mUpper && other.
includeEnd() && ! mIncludeUpper )
596 mIncludeUpper =
true;
619 if ( ranges.empty() )
622 QList< QgsTemporalRange<T > > sortedRanges = ranges;
624 QList< QgsTemporalRange<T>> res;
625 res.reserve( sortedRanges.size() );
628 auto it = sortedRanges.constBegin();
630 for ( ; it != sortedRanges.constEnd(); ++it )
649 return mLower == other.mLower &&
650 mUpper == other.mUpper &&
657 return ( !
operator==( other ) );
664 bool mIncludeLower =
true;
665 bool mIncludeUpper =
true;