mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
refs #356 Extend CVariant to support accessing properties by index of the contained value object.
This commit is contained in:
@@ -44,22 +44,54 @@ namespace BlackMisc
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare with CValueObject
|
||||
* Compare with CVariant
|
||||
*/
|
||||
bool operator==(const CPropertyIndexVariantMap &indexMap, const CValueObject &valueObject)
|
||||
bool operator==(const CPropertyIndexVariantMap &indexMap, const CVariant &variant)
|
||||
{
|
||||
if (indexMap.isEmpty()) return indexMap.isWildcard();
|
||||
const auto &map = indexMap.map();
|
||||
for (auto it = map.begin(); it != map.end(); ++it)
|
||||
{
|
||||
// QVariant cannot be compared directly
|
||||
CVariant p = valueObject.propertyByIndex(it.key()); // from value object
|
||||
CVariant p = variant.propertyByIndex(it.key()); // from value object
|
||||
CVariant v = it.value().toCVariant(); // from map
|
||||
if (p != v) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare with CVariant
|
||||
*/
|
||||
bool operator!=(const CPropertyIndexVariantMap &indexMap, const CVariant &variant)
|
||||
{
|
||||
return !(indexMap == variant);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare with CVariant
|
||||
*/
|
||||
bool operator==(const CVariant &variant, const CPropertyIndexVariantMap &valueMap)
|
||||
{
|
||||
return valueMap == variant;
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare with CVariant
|
||||
*/
|
||||
bool operator!=(const CVariant &variant, const CPropertyIndexVariantMap &valueMap)
|
||||
{
|
||||
return !(valueMap == variant);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare with CValueObject
|
||||
*/
|
||||
bool operator==(const CPropertyIndexVariantMap &indexMap, const CValueObject &valueObject)
|
||||
{
|
||||
return indexMap == valueObject.toCVariant();
|
||||
}
|
||||
|
||||
/*
|
||||
* Compare with CValueObject
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user