mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-22 21:35:40 +08:00
Ref T268, compare for PQs
This commit is contained in:
@@ -500,8 +500,13 @@ namespace BlackMisc
|
|||||||
template <class MU, class PQ>
|
template <class MU, class PQ>
|
||||||
int CPhysicalQuantity<MU, PQ>::compareImpl(const PQ &a, const PQ &b)
|
int CPhysicalQuantity<MU, PQ>::compareImpl(const PQ &a, const PQ &b)
|
||||||
{
|
{
|
||||||
if (a.isNull() > b.isNull()) { return -1; }
|
// fetch "null" as we do not know how expensive it is
|
||||||
if (a.isNull() < b.isNull()) { return 1; }
|
const bool aIsNull = a.isNull();
|
||||||
|
const bool bIsNull = b.isNull();
|
||||||
|
|
||||||
|
if (aIsNull && bIsNull) { return 0; }
|
||||||
|
if (aIsNull > bIsNull) { return -1; }
|
||||||
|
if (aIsNull < bIsNull) { return 1; }
|
||||||
|
|
||||||
if (a < b) { return -1; }
|
if (a < b) { return -1; }
|
||||||
else if (a > b) { return 1; }
|
else if (a > b) { return 1; }
|
||||||
|
|||||||
@@ -228,6 +228,9 @@ namespace BlackMisc
|
|||||||
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
//! \copydoc BlackMisc::Mixin::Index::setPropertyByIndex
|
||||||
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
void setPropertyByIndex(const CPropertyIndex &index, const CVariant &variant);
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::Mixin::Index::comparePropertyByIndex
|
||||||
|
int comparePropertyByIndex(const CPropertyIndex &index, const PQ &pq) const;
|
||||||
|
|
||||||
//! \copydoc BlackMisc::Mixin::String::toQString
|
//! \copydoc BlackMisc::Mixin::String::toQString
|
||||||
QString convertToQString(bool i18n = false) const;
|
QString convertToQString(bool i18n = false) const;
|
||||||
|
|
||||||
@@ -237,8 +240,8 @@ namespace BlackMisc
|
|||||||
//! Parse value from string
|
//! Parse value from string
|
||||||
void parseFromString(const QString &value);
|
void parseFromString(const QString &value);
|
||||||
|
|
||||||
//! Compare
|
//! Compare with other PQ
|
||||||
int comparePropertyByIndex(const CPropertyIndex &index, const PQ &pq) const;
|
int compare(const PQ &other) const { return compareImpl(*this->derived(), other); }
|
||||||
|
|
||||||
//! Maximum of 2 quantities
|
//! Maximum of 2 quantities
|
||||||
static const PQ &maxValue(const PQ &pq1, const PQ &pq2);
|
static const PQ &maxValue(const PQ &pq1, const PQ &pq2);
|
||||||
@@ -246,6 +249,9 @@ namespace BlackMisc
|
|||||||
//! Minimum of 2 quantities
|
//! Minimum of 2 quantities
|
||||||
static const PQ &minValue(const PQ &pq1, const PQ &pq2);
|
static const PQ &minValue(const PQ &pq1, const PQ &pq2);
|
||||||
|
|
||||||
|
//! Implementation of compare
|
||||||
|
static int compare(const PQ &a, const PQ &b) { return compareImpl(a, b); }
|
||||||
|
|
||||||
//! NULL PQ
|
//! NULL PQ
|
||||||
static const PQ &null();
|
static const PQ &null();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user