CFlagsProperty: Make use of a ranged for loop

This commit is contained in:
Lioncash 2020-06-14 17:06:46 -04:00
parent 84184da66d
commit d5a33b631a
1 changed files with 9 additions and 7 deletions

View File

@ -5,7 +5,7 @@ void CFlagsProperty::Serialize(IArchive& rArc)
{ {
TSerializeableTypedProperty::Serialize(rArc); TSerializeableTypedProperty::Serialize(rArc);
CFlagsProperty* pArchetype = static_cast<CFlagsProperty*>(mpArchetype); auto* pArchetype = static_cast<CFlagsProperty*>(mpArchetype);
if (!pArchetype || !rArc.CanSkipParameters() || mBitFlags != pArchetype->mBitFlags) if (!pArchetype || !rArc.CanSkipParameters() || mBitFlags != pArchetype->mBitFlags)
{ {
@ -20,26 +20,26 @@ void CFlagsProperty::PostInitialize()
// Create AllFlags mask // Create AllFlags mask
mAllFlags = 0; mAllFlags = 0;
for (int FlagIdx = 0; FlagIdx < mBitFlags.size(); FlagIdx++) for (const auto& flag : mBitFlags)
mAllFlags |= mBitFlags[FlagIdx].Mask; mAllFlags |= flag.Mask;
} }
void CFlagsProperty::SerializeValue(void* pData, IArchive& rArc) const void CFlagsProperty::SerializeValue(void* pData, IArchive& rArc) const
{ {
rArc.SerializePrimitive( (uint32&) ValueRef(pData), SH_HexDisplay ); rArc.SerializePrimitive((uint32&)ValueRef(pData), SH_HexDisplay);
} }
void CFlagsProperty::InitFromArchetype(IProperty* pOther) void CFlagsProperty::InitFromArchetype(IProperty* pOther)
{ {
TSerializeableTypedProperty::InitFromArchetype(pOther); TSerializeableTypedProperty::InitFromArchetype(pOther);
CFlagsProperty* pOtherFlags = static_cast<CFlagsProperty*>(pOther); auto* pOtherFlags = static_cast<CFlagsProperty*>(pOther);
mBitFlags = pOtherFlags->mBitFlags; mBitFlags = pOtherFlags->mBitFlags;
mAllFlags = pOtherFlags->mAllFlags; mAllFlags = pOtherFlags->mAllFlags;
} }
TString CFlagsProperty::ValueAsString(void* pData) const TString CFlagsProperty::ValueAsString(void* pData) const
{ {
return TString::FromInt32( Value(pData), 0, 10 ); return TString::FromInt32(Value(pData), 0, 10);
} }
/** /**
@ -48,6 +48,8 @@ TString CFlagsProperty::ValueAsString(void* pData) const
*/ */
uint32 CFlagsProperty::HasValidValue(void* pPropertyData) uint32 CFlagsProperty::HasValidValue(void* pPropertyData)
{ {
if (!mAllFlags) return 0; if (!mAllFlags)
return 0;
return ValueRef(pPropertyData) & ~mAllFlags; return ValueRef(pPropertyData) & ~mAllFlags;
} }