mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-21 04:45:31 +08:00
refs #893, property index
* added startsWith * added GlobalIndexCComSystem * renamed equalsPropertyIndexEnum -> startsWithPropertyIndexEnum
This commit is contained in:
committed by
Mathew Sutcliffe
parent
e90c65a33a
commit
5f5909c5b6
@@ -144,4 +144,9 @@ namespace BlackMisc
|
||||
return f;
|
||||
}
|
||||
|
||||
bool CPropertyIndex::startsWith(int index) const
|
||||
{
|
||||
if (this->isEmpty()) { return false; }
|
||||
return this->frontToInt() == index;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user