From 96876b70e03fb1516f73fd77ce5f968b52b4117b Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 10 Jun 2020 09:19:09 -0400 Subject: [PATCH] Property: Make use of override where applicable Makes the API strongly enforced. This also fixes a bug in CBoolProperty, where ValueAsString() had an incorrect signature (was missing a const). --- .../Script/Property/CAnimationProperty.h | 12 ++--- .../Script/Property/CAnimationSetProperty.h | 12 ++--- .../Resource/Script/Property/CArrayProperty.h | 50 ++++++++++--------- .../Resource/Script/Property/CAssetProperty.h | 14 +++--- .../Resource/Script/Property/CBoolProperty.h | 10 ++-- .../Resource/Script/Property/CByteProperty.h | 12 ++--- .../Resource/Script/Property/CColorProperty.h | 8 +-- .../Resource/Script/Property/CEnumProperty.h | 38 +++++++------- .../Resource/Script/Property/CFlagsProperty.h | 37 +++++++------- .../Resource/Script/Property/CFloatProperty.h | 12 ++--- .../Resource/Script/Property/CGuidProperty.h | 6 +-- .../Resource/Script/Property/CIntProperty.h | 12 ++--- .../Script/Property/CPointerProperty.h | 8 +-- .../Script/Property/CSequenceProperty.h | 6 +-- .../Resource/Script/Property/CShortProperty.h | 10 ++-- .../Resource/Script/Property/CSoundProperty.h | 12 ++--- .../Script/Property/CSplineProperty.h | 6 +-- .../Script/Property/CStringProperty.h | 10 ++-- .../Script/Property/CStructProperty.h | 34 ++++++------- .../Script/Property/CVectorProperty.h | 10 ++-- 20 files changed, 162 insertions(+), 157 deletions(-) diff --git a/src/Core/Resource/Script/Property/CAnimationProperty.h b/src/Core/Resource/Script/Property/CAnimationProperty.h index 30ce08f4..ee331c6f 100644 --- a/src/Core/Resource/Script/Property/CAnimationProperty.h +++ b/src/Core/Resource/Script/Property/CAnimationProperty.h @@ -3,24 +3,24 @@ #include "IProperty.h" -class CAnimationProperty : public TSerializeableTypedProperty< uint32, EPropertyType::Animation > +class CAnimationProperty : public TSerializeableTypedProperty { friend class IProperty; protected: - CAnimationProperty(EGame Game) + explicit CAnimationProperty(EGame Game) : TSerializeableTypedProperty(Game) {} public: - virtual void SerializeValue(void* pData, IArchive& rArc) const + void SerializeValue(void* pData, IArchive& rArc) const override { - rArc.SerializePrimitive( (uint32&) ValueRef(pData), SH_HexDisplay ); + rArc.SerializePrimitive((uint32&)ValueRef(pData), SH_HexDisplay); } - virtual TString ValueAsString(void* pData) const + TString ValueAsString(void* pData) const override { - return TString::HexString( (uint32) Value(pData) ); + return TString::HexString(static_cast(Value(pData))); } }; diff --git a/src/Core/Resource/Script/Property/CAnimationSetProperty.h b/src/Core/Resource/Script/Property/CAnimationSetProperty.h index 5248da64..51709ce6 100644 --- a/src/Core/Resource/Script/Property/CAnimationSetProperty.h +++ b/src/Core/Resource/Script/Property/CAnimationSetProperty.h @@ -9,26 +9,26 @@ class CAnimationSetProperty : public TSerializeableTypedProperty< CAnimationPara friend class IProperty; protected: - CAnimationSetProperty(EGame Game) + explicit CAnimationSetProperty(EGame Game) : TSerializeableTypedProperty(Game) { mDefaultValue.SetGame(Game); } public: - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { ValueRef(pData).Serialize(Arc); } - virtual const char* HashableTypeName() const + const char* HashableTypeName() const override { - return (Game() <= EGame::Echoes ? "AnimationSet" : "CharacterAnimationSet"); + return Game() <= EGame::Echoes ? "AnimationSet" : "CharacterAnimationSet"; } - virtual CAnimationParameters GetSerializationDefaultValue() + CAnimationParameters GetSerializationDefaultValue() override { - return CAnimationParameters( Game() ); + return CAnimationParameters(Game()); } }; diff --git a/src/Core/Resource/Script/Property/CArrayProperty.h b/src/Core/Resource/Script/Property/CArrayProperty.h index 3ec53da4..fca51c36 100644 --- a/src/Core/Resource/Script/Property/CArrayProperty.h +++ b/src/Core/Resource/Script/Property/CArrayProperty.h @@ -5,16 +5,19 @@ struct SScriptArray { - int Count; + int Count = 0; std::vector Array; - SScriptArray() - : Count(0) - {} + SScriptArray() = default; - inline bool operator==(const SScriptArray& rkOther) const + bool operator==(const SScriptArray& other) const { - return( Count == rkOther.Count && Array == rkOther.Array ); + return Count == other.Count && Array == other.Array; + } + + bool operator!=(const SScriptArray& other) const + { + return !operator==(other); } }; @@ -29,7 +32,7 @@ class CArrayProperty : public TTypedProperty * value and we respond by updating the allocated space, handling item destruction * and construction, etc. */ - IProperty* mpItemArchetype; + IProperty* mpItemArchetype = nullptr; /** Internal functions */ SScriptArray& _GetInternalArray(void* pData) const @@ -44,75 +47,74 @@ class CArrayProperty : public TTypedProperty } protected: - CArrayProperty(EGame Game) + explicit CArrayProperty(EGame Game) : TTypedProperty(Game) - , mpItemArchetype(nullptr) {} public: - virtual ~CArrayProperty() { delete mpItemArchetype; } + ~CArrayProperty() override { delete mpItemArchetype; } - virtual uint32 DataSize() const + uint32 DataSize() const override { return sizeof(SScriptArray); } - virtual uint32 DataAlignment() const + uint32 DataAlignment() const override { return alignof(SScriptArray); } - virtual void Construct(void* pData) const + void Construct(void* pData) const override { new(ValuePtr(pData)) SScriptArray; } - virtual void Destruct(void* pData) const + void Destruct(void* pData) const override { RevertToDefault(pData); _GetInternalArray(pData).~SScriptArray(); } - virtual bool MatchesDefault(void* pData) const + bool MatchesDefault(void* pData) const override { return ArrayCount(pData) == 0; } - virtual void RevertToDefault(void* pData) const + void RevertToDefault(void* pData) const override { Resize(pData, 0); ValueRef(pData) = 0; } - virtual bool CanHaveDefault() const + bool CanHaveDefault() const override { return true; } - virtual bool IsPointerType() const + bool IsPointerType() const override { return true; } - virtual void* GetChildDataPointer(void* pPropertyData) const + void* GetChildDataPointer(void* pPropertyData) const override { return _GetInternalArray(pPropertyData).Array.data(); } - virtual void PropertyValueChanged(void* pPropertyData) + void PropertyValueChanged(void* pPropertyData) override { SScriptArray& rArray = _GetInternalArray(pPropertyData); rArray.Count = Math::Max(rArray.Count, 0); Resize(pPropertyData, rArray.Count); } - virtual void Serialize(IArchive& rArc) + void Serialize(IArchive& rArc) override { TTypedProperty::Serialize(rArc); rArc << SerialParameter("ItemArchetype", mpItemArchetype); } - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { uint32 Count = ArrayCount(pData); Arc.SerializeArraySize(Count); @@ -131,14 +133,14 @@ public: } } - virtual void InitFromArchetype(IProperty* pOther) + void InitFromArchetype(IProperty* pOther) override { TTypedProperty::InitFromArchetype(pOther); CArrayProperty* pOtherArray = static_cast(pOther); mpItemArchetype = IProperty::CreateCopy(pOtherArray->mpItemArchetype); } - virtual void PostInitialize() + void PostInitialize() override { TTypedProperty::PostInitialize(); mpItemArchetype->Initialize(this, mpScriptTemplate, 0); diff --git a/src/Core/Resource/Script/Property/CAssetProperty.h b/src/Core/Resource/Script/Property/CAssetProperty.h index 48becd00..3f4315f9 100644 --- a/src/Core/Resource/Script/Property/CAssetProperty.h +++ b/src/Core/Resource/Script/Property/CAssetProperty.h @@ -11,44 +11,44 @@ class CAssetProperty : public TSerializeableTypedProperty(mpArchetype); rArc << SerialParameter("TypeFilter", mTypeFilter, pArchetype ? SH_Optional : 0, pArchetype ? pArchetype->mTypeFilter : CResTypeFilter()); } - virtual bool ShouldSerialize() const + bool ShouldSerialize() const override { CAssetProperty* pArchetype = static_cast(mpArchetype); return TSerializeableTypedProperty::ShouldSerialize() || mTypeFilter != pArchetype->mTypeFilter; } - virtual void InitFromArchetype(IProperty* pOther) + void InitFromArchetype(IProperty* pOther) override { TTypedProperty::InitFromArchetype(pOther); mTypeFilter = static_cast(pOther)->mTypeFilter; } - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { Arc.SerializePrimitive( ValueRef(pData), 0 ); } - virtual TString ValueAsString(void* pData) const + TString ValueAsString(void* pData) const override { return Value(pData).ToString(); } - virtual CAssetID GetSerializationDefaultValue() + CAssetID GetSerializationDefaultValue() override { return CAssetID::InvalidID(Game()); } diff --git a/src/Core/Resource/Script/Property/CBoolProperty.h b/src/Core/Resource/Script/Property/CBoolProperty.h index 994807cb..42e6860e 100644 --- a/src/Core/Resource/Script/Property/CBoolProperty.h +++ b/src/Core/Resource/Script/Property/CBoolProperty.h @@ -3,22 +3,22 @@ #include "IProperty.h" -class CBoolProperty : public TSerializeableTypedProperty< bool, EPropertyType::Bool > +class CBoolProperty : public TSerializeableTypedProperty { friend class IProperty; protected: - CBoolProperty(EGame Game) + explicit CBoolProperty(EGame Game) : TSerializeableTypedProperty(Game) {} public: - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { - Arc.SerializePrimitive( ValueRef(pData), 0 ); + Arc.SerializePrimitive(ValueRef(pData), 0); } - virtual TString ValueAsString(void* pData) + TString ValueAsString(void* pData) const override { return Value(pData) ? "true" : "false"; } diff --git a/src/Core/Resource/Script/Property/CByteProperty.h b/src/Core/Resource/Script/Property/CByteProperty.h index b23cfa1a..4e97dd64 100644 --- a/src/Core/Resource/Script/Property/CByteProperty.h +++ b/src/Core/Resource/Script/Property/CByteProperty.h @@ -3,24 +3,24 @@ #include "IProperty.h" -class CByteProperty : public TNumericalProperty< int8, EPropertyType::Byte > +class CByteProperty : public TNumericalProperty { friend class IProperty; protected: - CByteProperty(EGame Game) + explicit CByteProperty(EGame Game) : TNumericalProperty(Game) {} public: - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { - Arc.SerializePrimitive( (int8&) ValueRef(pData), 0 ); + Arc.SerializePrimitive((int8&)ValueRef(pData), 0); } - virtual TString ValueAsString(void* pData) const + TString ValueAsString(void* pData) const override { - return TString::FromInt32( (int32) Value(pData), 0, 10 ); + return TString::FromInt32((int32)Value(pData), 0, 10); } }; diff --git a/src/Core/Resource/Script/Property/CColorProperty.h b/src/Core/Resource/Script/Property/CColorProperty.h index 12c0c3bb..adb7ac76 100644 --- a/src/Core/Resource/Script/Property/CColorProperty.h +++ b/src/Core/Resource/Script/Property/CColorProperty.h @@ -4,17 +4,17 @@ #include "IProperty.h" #include "CFloatProperty.h" -class CColorProperty : public TSerializeableTypedProperty< CColor, EPropertyType::Color > +class CColorProperty : public TSerializeableTypedProperty { friend class IProperty; protected: - CColorProperty(EGame Game) + explicit CColorProperty(EGame Game) : TSerializeableTypedProperty(Game) {} public: - virtual void PostInitialize() + void PostInitialize() override { CreateIntrinsic(EPropertyType::Float, this, mOffset + 0, "R"); CreateIntrinsic(EPropertyType::Float, this, mOffset + 4, "G"); @@ -23,7 +23,7 @@ public: TPropCast( mChildren.back() )->SetDefaultValue(1.0f); } - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { ValueRef(pData).Serialize(Arc); } diff --git a/src/Core/Resource/Script/Property/CEnumProperty.h b/src/Core/Resource/Script/Property/CEnumProperty.h index 55bfc9e7..abcce278 100644 --- a/src/Core/Resource/Script/Property/CEnumProperty.h +++ b/src/Core/Resource/Script/Property/CEnumProperty.h @@ -19,19 +19,21 @@ class TEnumPropertyBase : public TSerializeableTypedProperty struct SEnumValue { TString Name; - uint32 ID; - - SEnumValue() - : ID(0) - {} + uint32 ID = 0; + SEnumValue() = default; SEnumValue(const TString& rkInName, uint32 InID) : Name(rkInName), ID(InID) {} - inline bool operator==(const SEnumValue& rkOther) const + bool operator==(const SEnumValue& other) const { - return( Name == rkOther.Name && ID == rkOther.ID ); + return Name == other.Name && ID == other.ID; + } + + bool operator!=(const SEnumValue& other) const + { + return !operator==(other); } void Serialize(IArchive& rArc) @@ -47,13 +49,13 @@ class TEnumPropertyBase : public TSerializeableTypedProperty protected: /** Constructor */ - TEnumPropertyBase(EGame Game) + explicit TEnumPropertyBase(EGame Game) : base(Game) , mOverrideTypeName(false) {} public: - virtual const char* HashableTypeName() const + const char* HashableTypeName() const override { if (base::mpArchetype) return base::mpArchetype->HashableTypeName(); @@ -65,7 +67,7 @@ public: return "choice"; } - virtual void Serialize(IArchive& rArc) + void Serialize(IArchive& rArc) override { // Skip TSerializeableTypedProperty, serialize default value ourselves so we can set SH_HexDisplay TTypedProperty::Serialize(rArc); @@ -87,21 +89,21 @@ public: } } - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { - Arc.SerializePrimitive( (uint32&) base::ValueRef(pData), 0 ); + Arc.SerializePrimitive((uint32&)base::ValueRef(pData), 0); } - virtual void InitFromArchetype(IProperty* pOther) + void InitFromArchetype(IProperty* pOther) override { TTypedProperty::InitFromArchetype(pOther); TEnumPropertyBase* pOtherEnum = static_cast(pOther); mValues = pOtherEnum->mValues; } - virtual TString ValueAsString(void* pData) const + TString ValueAsString(void* pData) const override { - return TString::FromInt32( base::Value(pData), 0, 10 ); + return TString::FromInt32(base::Value(pData), 0, 10); } void AddValue(TString ValueName, uint32 ValueID) @@ -109,7 +111,7 @@ public: mValues.push_back( SEnumValue(ValueName, ValueID) ); } - inline uint32 NumPossibleValues() const { return mValues.size(); } + uint32 NumPossibleValues() const { return mValues.size(); } uint32 ValueIndex(uint32 ID) const { @@ -166,8 +168,8 @@ public: } }; -typedef TEnumPropertyBase CChoiceProperty; -typedef TEnumPropertyBase CEnumProperty; +using CChoiceProperty = TEnumPropertyBase; +using CEnumProperty = TEnumPropertyBase; // Specialization of TPropCast to allow interchangeable casting, as both types are the same thing template<> diff --git a/src/Core/Resource/Script/Property/CFlagsProperty.h b/src/Core/Resource/Script/Property/CFlagsProperty.h index 61cc3236..d88bedb9 100644 --- a/src/Core/Resource/Script/Property/CFlagsProperty.h +++ b/src/Core/Resource/Script/Property/CFlagsProperty.h @@ -10,19 +10,21 @@ class CFlagsProperty : public TSerializeableTypedProperty mBitFlags; - uint32 mAllFlags; + uint32 mAllFlags = 0; - CFlagsProperty(EGame Game) + explicit CFlagsProperty(EGame Game) : TSerializeableTypedProperty(Game) - , mAllFlags(0) {} public: - inline uint32 NumFlags() const + uint32 NumFlags() const { return mBitFlags.size(); } - inline TString FlagName(uint32 Idx) const + TString FlagName(uint32 Idx) const { ASSERT(Idx >= 0 && Idx < mBitFlags.size()); return mBitFlags[Idx].Name; } - inline uint32 FlagMask(uint32 Idx) const + uint32 FlagMask(uint32 Idx) const { ASSERT(Idx >= 0 && Idx < mBitFlags.size()); return mBitFlags[Idx].Mask; } - virtual void Serialize(IArchive& rArc); - virtual void PostInitialize(); - virtual void SerializeValue(void* pData, IArchive& rArc) const; - virtual void InitFromArchetype(IProperty* pOther); - virtual TString ValueAsString(void* pData) const; + void Serialize(IArchive& rArc) override; + void PostInitialize() override; + void SerializeValue(void* pData, IArchive& rArc) const override; + void InitFromArchetype(IProperty* pOther) override; + TString ValueAsString(void* pData) const override; /** * Checks whether there are any unrecognized bits toggled on in the property value. diff --git a/src/Core/Resource/Script/Property/CFloatProperty.h b/src/Core/Resource/Script/Property/CFloatProperty.h index f73de593..ce8f4a13 100644 --- a/src/Core/Resource/Script/Property/CFloatProperty.h +++ b/src/Core/Resource/Script/Property/CFloatProperty.h @@ -3,24 +3,24 @@ #include "IProperty.h" -class CFloatProperty : public TNumericalProperty< float, EPropertyType::Float > +class CFloatProperty : public TNumericalProperty { friend class IProperty; protected: - CFloatProperty(EGame Game) + explicit CFloatProperty(EGame Game) : TNumericalProperty(Game) {} public: - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { - Arc.SerializePrimitive( (float&) ValueRef(pData), 0 ); + Arc.SerializePrimitive((float&)ValueRef(pData), 0); } - virtual TString ValueAsString(void* pData) const + TString ValueAsString(void* pData) const override { - return TString::FromFloat( Value(pData) ); + return TString::FromFloat(Value(pData)); } }; diff --git a/src/Core/Resource/Script/Property/CGuidProperty.h b/src/Core/Resource/Script/Property/CGuidProperty.h index 197f05cc..24f8a414 100644 --- a/src/Core/Resource/Script/Property/CGuidProperty.h +++ b/src/Core/Resource/Script/Property/CGuidProperty.h @@ -3,17 +3,17 @@ #include "IProperty.h" -class CGuidProperty : public TTypedProperty< std::vector, EPropertyType::Guid > +class CGuidProperty : public TTypedProperty, EPropertyType::Guid> { friend class IProperty; protected: - CGuidProperty(EGame Game) + explicit CGuidProperty(EGame Game) : TTypedProperty(Game) {} public: - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { Arc << SerialParameter("Data", ValueRef(pData)); } diff --git a/src/Core/Resource/Script/Property/CIntProperty.h b/src/Core/Resource/Script/Property/CIntProperty.h index 3d1d5c73..f6187390 100644 --- a/src/Core/Resource/Script/Property/CIntProperty.h +++ b/src/Core/Resource/Script/Property/CIntProperty.h @@ -3,24 +3,24 @@ #include "IProperty.h" -class CIntProperty : public TNumericalProperty< int32, EPropertyType::Int > +class CIntProperty : public TNumericalProperty { friend class IProperty; protected: - CIntProperty(EGame Game) + explicit CIntProperty(EGame Game) : TNumericalProperty(Game) {} public: - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { - Arc.SerializePrimitive( ValueRef(pData), 0 ); + Arc.SerializePrimitive(ValueRef(pData), 0); } - virtual TString ValueAsString(void* pData) const + TString ValueAsString(void* pData) const override { - return TString::FromInt32( Value(pData), 0, 10 ); + return TString::FromInt32(Value(pData), 0, 10); } }; diff --git a/src/Core/Resource/Script/Property/CPointerProperty.h b/src/Core/Resource/Script/Property/CPointerProperty.h index 7e61a805..f09440f6 100644 --- a/src/Core/Resource/Script/Property/CPointerProperty.h +++ b/src/Core/Resource/Script/Property/CPointerProperty.h @@ -7,22 +7,22 @@ class CPointerProperty : public TTypedProperty { friend class IProperty; - CPointerProperty(EGame Game) + explicit CPointerProperty(EGame Game) : TTypedProperty(Game) {} public: - virtual bool IsPointerType() const + bool IsPointerType() const override { return true; } - virtual void* GetChildDataPointer(void* pPropertyData) const + void* GetChildDataPointer(void* pPropertyData) const override { return ValueRef(pPropertyData); } - virtual void SerializeValue(void* pData, IArchive& rArc) const + void SerializeValue(void* pData, IArchive& rArc) const override { // pointers are not serializable, this shouldn't happen ASSERT(false); diff --git a/src/Core/Resource/Script/Property/CSequenceProperty.h b/src/Core/Resource/Script/Property/CSequenceProperty.h index 59f49228..f2218256 100644 --- a/src/Core/Resource/Script/Property/CSequenceProperty.h +++ b/src/Core/Resource/Script/Property/CSequenceProperty.h @@ -3,16 +3,16 @@ #include "IProperty.h" -class CSequenceProperty : public TTypedProperty< int32, EPropertyType::Sequence > +class CSequenceProperty : public TTypedProperty { friend class IProperty; protected: - CSequenceProperty(EGame Game) + explicit CSequenceProperty(EGame Game) : TTypedProperty(Game) {} - virtual void SerializeValue(void* pData, IArchive& rArc) const + void SerializeValue(void* pData, IArchive& rArc) const override {} }; diff --git a/src/Core/Resource/Script/Property/CShortProperty.h b/src/Core/Resource/Script/Property/CShortProperty.h index 4b5ad2a2..7bf3e5d9 100644 --- a/src/Core/Resource/Script/Property/CShortProperty.h +++ b/src/Core/Resource/Script/Property/CShortProperty.h @@ -8,19 +8,19 @@ class CShortProperty : public TNumericalProperty< int16, EPropertyType::Short > friend class IProperty; protected: - CShortProperty(EGame Game) + explicit CShortProperty(EGame Game) : TNumericalProperty(Game) {} public: - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { - Arc.SerializePrimitive( ValueRef(pData), 0 ); + Arc.SerializePrimitive(ValueRef(pData), 0); } - virtual TString ValueAsString(void* pData) const + TString ValueAsString(void* pData) const override { - return TString::FromInt32( (int32) Value(pData), 0, 10 ); + return TString::FromInt32((int32)Value(pData), 0, 10); } }; diff --git a/src/Core/Resource/Script/Property/CSoundProperty.h b/src/Core/Resource/Script/Property/CSoundProperty.h index d15f748e..32738ed2 100644 --- a/src/Core/Resource/Script/Property/CSoundProperty.h +++ b/src/Core/Resource/Script/Property/CSoundProperty.h @@ -3,24 +3,24 @@ #include "IProperty.h" -class CSoundProperty : public TSerializeableTypedProperty< int32, EPropertyType::Sound > +class CSoundProperty : public TSerializeableTypedProperty { friend class IProperty; protected: - CSoundProperty(EGame Game) + explicit CSoundProperty(EGame Game) : TSerializeableTypedProperty(Game) {} public: - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { - Arc.SerializePrimitive( ValueRef(pData), 0 ); + Arc.SerializePrimitive(ValueRef(pData), 0); } - virtual TString ValueAsString(void* pData) const + TString ValueAsString(void* pData) const override { - return TString::FromInt32( Value(pData), 0, 10 ); + return TString::FromInt32(Value(pData), 0, 10); } }; diff --git a/src/Core/Resource/Script/Property/CSplineProperty.h b/src/Core/Resource/Script/Property/CSplineProperty.h index 4c3e1949..43910a68 100644 --- a/src/Core/Resource/Script/Property/CSplineProperty.h +++ b/src/Core/Resource/Script/Property/CSplineProperty.h @@ -3,17 +3,17 @@ #include "IProperty.h" -class CSplineProperty : public TTypedProperty< std::vector, EPropertyType::Spline > +class CSplineProperty : public TTypedProperty, EPropertyType::Spline> { friend class IProperty; protected: - CSplineProperty(EGame Game) + explicit CSplineProperty(EGame Game) : TTypedProperty(Game) {} public: - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { Arc << SerialParameter("Data", ValueRef(pData)); } diff --git a/src/Core/Resource/Script/Property/CStringProperty.h b/src/Core/Resource/Script/Property/CStringProperty.h index b2053226..3a9fc1ea 100644 --- a/src/Core/Resource/Script/Property/CStringProperty.h +++ b/src/Core/Resource/Script/Property/CStringProperty.h @@ -3,22 +3,22 @@ #include "IProperty.h" -class CStringProperty : public TSerializeableTypedProperty< TString, EPropertyType::String > +class CStringProperty : public TSerializeableTypedProperty { friend class IProperty; protected: - CStringProperty(EGame Game) + explicit CStringProperty(EGame Game) : TSerializeableTypedProperty(Game) {} public: - virtual void SerializeValue(void* pData, IArchive& Arc) const + void SerializeValue(void* pData, IArchive& Arc) const override { - Arc.SerializePrimitive( ValueRef(pData), 0 ); + Arc.SerializePrimitive(ValueRef(pData), 0); } - virtual TString ValueAsString(void* pData) const + TString ValueAsString(void* pData) const override { return Value(pData); } diff --git a/src/Core/Resource/Script/Property/CStructProperty.h b/src/Core/Resource/Script/Property/CStructProperty.h index 4a42c742..18824860 100644 --- a/src/Core/Resource/Script/Property/CStructProperty.h +++ b/src/Core/Resource/Script/Property/CStructProperty.h @@ -9,30 +9,30 @@ class CStructProperty : public IProperty public: // Must be a valid type for TPropertyRef - typedef void* ValueType; + using ValueType = void*; protected: - CStructProperty(EGame Game) + explicit CStructProperty(EGame Game) : IProperty(Game) {} public: - virtual EPropertyType Type() const; - virtual void PostInitialize(); - virtual uint32 DataSize() const; - virtual uint32 DataAlignment() const; - virtual void Construct(void* pData) const; - virtual void Destruct(void* pData) const; - virtual bool MatchesDefault(void* pData) const; - virtual void RevertToDefault(void* pData) const; - virtual void SetDefaultFromData(void* pData); - virtual const char* HashableTypeName() const; - virtual void Serialize(IArchive& rArc); - virtual void SerializeValue(void* pData, IArchive& Arc) const; - virtual void InitFromArchetype(IProperty* pOther); - virtual bool ShouldSerialize() const; + EPropertyType Type() const override; + void PostInitialize() override; + uint32 DataSize() const override; + uint32 DataAlignment() const override; + void Construct(void* pData) const override; + void Destruct(void* pData) const override; + bool MatchesDefault(void* pData) const override; + void RevertToDefault(void* pData) const override; + void SetDefaultFromData(void* pData) override; + const char* HashableTypeName() const override; + void Serialize(IArchive& rArc) override; + void SerializeValue(void* pData, IArchive& Arc) const override; + void InitFromArchetype(IProperty* pOther) override; + bool ShouldSerialize() const override; - inline static EPropertyType StaticType() { return EPropertyType::Struct; } + static EPropertyType StaticType() { return EPropertyType::Struct; } }; #endif diff --git a/src/Core/Resource/Script/Property/CVectorProperty.h b/src/Core/Resource/Script/Property/CVectorProperty.h index 51ff7b8d..ecd6336a 100644 --- a/src/Core/Resource/Script/Property/CVectorProperty.h +++ b/src/Core/Resource/Script/Property/CVectorProperty.h @@ -3,29 +3,29 @@ #include "IProperty.h" -class CVectorProperty : public TSerializeableTypedProperty< CVector3f, EPropertyType::Vector > +class CVectorProperty : public TSerializeableTypedProperty { friend class IProperty; protected: - CVectorProperty(EGame Game) + explicit CVectorProperty(EGame Game) : TSerializeableTypedProperty(Game) {} public: - virtual void PostInitialize() override + void PostInitialize() override { CreateIntrinsic(EPropertyType::Float, this, mOffset + 0, "X"); CreateIntrinsic(EPropertyType::Float, this, mOffset + 4, "Y"); CreateIntrinsic(EPropertyType::Float, this, mOffset + 8, "Z"); } - virtual void SerializeValue(void* pData, IArchive& Arc) const override + void SerializeValue(void* pData, IArchive& Arc) const override { ValueRef(pData).Serialize(Arc); } - virtual TString ValueAsString(void* pData) const override + TString ValueAsString(void* pData) const override { return Value(pData).ToString(); }