mirror of
https://github.com/AxioDL/PrimeWorldEditor.git
synced 2025-06-19 04:53:42 +00:00
CStructProperty: Make use of ranged for
This commit is contained in:
parent
7b40eec19c
commit
f0cd6ee99b
@ -1,5 +1,6 @@
|
|||||||
#include "CStructProperty.h"
|
#include "CStructProperty.h"
|
||||||
#include "Core/Resource/Script/CGameTemplate.h"
|
#include "Core/Resource/Script/CGameTemplate.h"
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
EPropertyType CStructProperty::Type() const
|
EPropertyType CStructProperty::Type() const
|
||||||
{
|
{
|
||||||
@ -35,45 +36,39 @@ uint32 CStructProperty::DataAlignment() const
|
|||||||
|
|
||||||
void CStructProperty::Construct(void* pData) const
|
void CStructProperty::Construct(void* pData) const
|
||||||
{
|
{
|
||||||
for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
|
for (auto* child : mChildren)
|
||||||
{
|
{
|
||||||
mChildren[ChildIdx]->Construct(pData);
|
child->Construct(pData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStructProperty::Destruct(void* pData) const
|
void CStructProperty::Destruct(void* pData) const
|
||||||
{
|
{
|
||||||
for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
|
for (auto* child : mChildren)
|
||||||
{
|
{
|
||||||
mChildren[ChildIdx]->Destruct(pData);
|
child->Destruct(pData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CStructProperty::MatchesDefault(void* pData) const
|
bool CStructProperty::MatchesDefault(void* pData) const
|
||||||
{
|
{
|
||||||
for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
|
return std::any_of(mChildren.cbegin(), mChildren.cend(),
|
||||||
{
|
[pData](const auto* child) { return child->MatchesDefault(pData); });
|
||||||
if (!mChildren[ChildIdx]->MatchesDefault(pData))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStructProperty::RevertToDefault(void* pData) const
|
void CStructProperty::RevertToDefault(void* pData) const
|
||||||
{
|
{
|
||||||
for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
|
for (auto* child : mChildren)
|
||||||
{
|
{
|
||||||
mChildren[ChildIdx]->RevertToDefault(pData);
|
child->RevertToDefault(pData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CStructProperty::SetDefaultFromData(void* pData)
|
void CStructProperty::SetDefaultFromData(void* pData)
|
||||||
{
|
{
|
||||||
for (int ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
|
for (auto* child : mChildren)
|
||||||
{
|
{
|
||||||
mChildren[ChildIdx]->SetDefaultFromData(pData);
|
child->SetDefaultFromData(pData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,11 +137,11 @@ void CStructProperty::Serialize(IArchive& rArc)
|
|||||||
// Check if any properties need to override parameters from their archetype.
|
// Check if any properties need to override parameters from their archetype.
|
||||||
std::vector<IProperty*> PropertiesToSerialize;
|
std::vector<IProperty*> PropertiesToSerialize;
|
||||||
|
|
||||||
for (uint32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
|
for (auto* child : mChildren)
|
||||||
{
|
{
|
||||||
if (mChildren[ChildIdx]->ShouldSerialize())
|
if (child->ShouldSerialize())
|
||||||
{
|
{
|
||||||
PropertiesToSerialize.push_back(mChildren[ChildIdx]);
|
PropertiesToSerialize.push_back(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,11 +161,11 @@ void CStructProperty::Serialize(IArchive& rArc)
|
|||||||
|
|
||||||
void CStructProperty::SerializeValue(void* pData, IArchive& Arc) const
|
void CStructProperty::SerializeValue(void* pData, IArchive& Arc) const
|
||||||
{
|
{
|
||||||
for (uint32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
|
for (auto* child : mChildren)
|
||||||
{
|
{
|
||||||
if (Arc.ParamBegin("Property", 0))
|
if (Arc.ParamBegin("Property", 0))
|
||||||
{
|
{
|
||||||
mChildren[ChildIdx]->SerializeValue(pData, Arc);
|
child->SerializeValue(pData, Arc);
|
||||||
Arc.ParamEnd();
|
Arc.ParamEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -196,11 +191,6 @@ bool CStructProperty::ShouldSerialize() const
|
|||||||
if (IProperty::ShouldSerialize())
|
if (IProperty::ShouldSerialize())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (uint32 ChildIdx = 0; ChildIdx < mChildren.size(); ChildIdx++)
|
return std::any_of(mChildren.cbegin(), mChildren.cend(),
|
||||||
{
|
[](const auto* child) { return child->ShouldSerialize(); });
|
||||||
if (mChildren[ChildIdx]->ShouldSerialize())
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user