refs #893, property index

* added startsWith
* added GlobalIndexCComSystem
* renamed equalsPropertyIndexEnum -> startsWithPropertyIndexEnum
This commit is contained in:
Klaus Basan
2017-03-01 00:53:13 +01:00
committed by Mathew Sutcliffe
parent e90c65a33a
commit 5f5909c5b6
2 changed files with 13 additions and 6 deletions

View File

@@ -144,4 +144,9 @@ namespace BlackMisc
return f;
}
bool CPropertyIndex::startsWith(int index) const
{
if (this->isEmpty()) { return false; }
return this->frontToInt() == index;
}
} // namespace

View File

@@ -93,8 +93,9 @@ namespace BlackMisc
GlobalIndexCAircraftParts = 1400,
GlobalIndexCAircraftLights = 1500,
GlobalIndexCLivery = 1600,
GlobalIndexCModulator = 2000,
GlobalIndexCTransponder = 2100,
GlobalIndexCComSystem = 2000,
GlobalIndexCModulator = 2100,
GlobalIndexCTransponder = 2200,
GlobalIndexCAircraftIcaoData = 2500,
GlobalIndexCAircraftIcaoCode = 2600,
GlobalIndexCAirlineIcaoCode = 2700,
@@ -202,6 +203,9 @@ namespace BlackMisc
//! Front to integer
int frontToInt() const;
//! Starts with given index?
bool startsWith(int index) const;
//! First element casted to given type, usually the PropertIndex enum
template<class CastType> CastType frontCasted() const
{
@@ -210,12 +214,10 @@ namespace BlackMisc
}
//! Compare with index given by enum
template<class EnumType> bool equalsPropertyIndexEnum(EnumType ev)
template<class EnumType> bool startsWithPropertyIndexEnum(EnumType ev) const
{
static_assert(std::is_enum<EnumType>::value, "Argument must be an enum");
QList<int> l = indexList();
if (l.size() != 1) { return false; }
return static_cast<int>(ev) == l.first();
return this->startsWith(static_cast<int>(ev));
}
//! Return a predicate function which can compare two objects based on this index