diff --git a/Toshi/Plugins/Include/PPropertyParser/PPropertyValue.h b/Toshi/Plugins/Include/PPropertyParser/PPropertyValue.h index 6edf7a7..ebfa686 100644 --- a/Toshi/Plugins/Include/PPropertyParser/PPropertyValue.h +++ b/Toshi/Plugins/Include/PPropertyParser/PPropertyValue.h @@ -83,12 +83,14 @@ class PPROPERTYPARSER_EXPORTS PPropertyValue Toshi::TManagedPtr &GetPropertiesMP() { TASSERT(TYPE_PROPS == m_type); - return *(Toshi::TManagedPtr *)m_valueProps; + Toshi::TManagedPtr value(m_valueProps); + return value; } Toshi::TManagedPtr &GetPropArrayMP() { TASSERT(TYPE_ARRAY == m_type); - return *(Toshi::TManagedPtr *)m_valueArray; + Toshi::TManagedPtr value(m_valueArray); + return value; } public: @@ -105,16 +107,16 @@ class PPROPERTYPARSER_EXPORTS PPropertyValue } public: - static const Toshi::TClass *TYPE_ARRAY; - static const Toshi::TClass *TYPE_BOOL; - static const Toshi::TClass *TYPE_FLOAT; static const Toshi::TClass *TYPE_INT; - static const Toshi::TClass *TYPE_PROPNAME; - static const Toshi::TClass *TYPE_PROPS; - static const Toshi::TClass *TYPE_TLSTRING; + static const Toshi::TClass *TYPE_UINT32; + static const Toshi::TClass *TYPE_FLOAT; + static const Toshi::TClass *TYPE_BOOL; static const Toshi::TClass *TYPE_TPCSTRING; static const Toshi::TClass *TYPE_TPWSTRING; - static const Toshi::TClass *TYPE_UINT32; + static const Toshi::TClass *TYPE_TLSTRING; + static const Toshi::TClass *TYPE_PROPNAME; + static const Toshi::TClass *TYPE_ARRAY; + static const Toshi::TClass *TYPE_PROPS; static const Toshi::TClass *TYPE_UNDEF; private: diff --git a/Toshi/Plugins/Source/PPropertyParser/PPropertyValue.cpp b/Toshi/Plugins/Source/PPropertyParser/PPropertyValue.cpp index a8c63bb..0dea22e 100644 --- a/Toshi/Plugins/Source/PPropertyParser/PPropertyValue.cpp +++ b/Toshi/Plugins/Source/PPropertyParser/PPropertyValue.cpp @@ -3,70 +3,74 @@ TOSHI_NAMESPACE_USING -class PArray : TObject +namespace ValueType { + +class INT : TObject { - DECLARE_DYNAMIC(PArray); + DECLARE_DYNAMIC(INT); }; -IMPLEMENT_DYNCREATE(PArray, TObject); +IMPLEMENT_DYNCREATE(INT, TObject); -class PBool : TObject +class UINT32 : TObject { - DECLARE_DYNAMIC(PBool); + DECLARE_DYNAMIC(UINT32); }; -IMPLEMENT_DYNCREATE(PBool, TObject); +IMPLEMENT_DYNCREATE(UINT32, TObject); -class PFloat : TObject +class FLOAT : TObject { - DECLARE_DYNAMIC(PFloat); + DECLARE_DYNAMIC(FLOAT); }; -IMPLEMENT_DYNCREATE(PFloat, TObject); +IMPLEMENT_DYNCREATE(FLOAT, TObject); -class PInt : TObject +class BOOL : TObject { - DECLARE_DYNAMIC(PInt); + DECLARE_DYNAMIC(BOOL); }; -IMPLEMENT_DYNCREATE(PInt, TObject); +IMPLEMENT_DYNCREATE(BOOL, TObject); -class PPropName : TObject +class TPCString : TObject { - DECLARE_DYNAMIC(PPropName); + DECLARE_DYNAMIC(TPCString); }; -IMPLEMENT_DYNCREATE(PPropName, TObject); +IMPLEMENT_DYNCREATE(TPCString, TObject); -class PLString : TObject +class TPWString : TObject { - DECLARE_DYNAMIC(PLString); + DECLARE_DYNAMIC(TPWString); }; -IMPLEMENT_DYNCREATE(PLString, TObject); +IMPLEMENT_DYNCREATE(TPWString, TObject); -class PCString : TObject +class TLString : TObject { - DECLARE_DYNAMIC(PCString); + DECLARE_DYNAMIC(TLString); }; -IMPLEMENT_DYNCREATE(PCString, TObject); +IMPLEMENT_DYNCREATE(TLString, TObject); -class PWString : TObject +class PPropertyName : TObject { - DECLARE_DYNAMIC(PWString); + DECLARE_DYNAMIC(PPropertyName); }; -IMPLEMENT_DYNCREATE(PWString, TObject); +IMPLEMENT_DYNCREATE(PPropertyName, TObject); -class PPUINT32 : TObject +class PPropertyValueArray : TObject { - DECLARE_DYNAMIC(PPUINT32); + DECLARE_DYNAMIC(PPropertyValueArray); }; -IMPLEMENT_DYNCREATE(PPUINT32, TObject); +IMPLEMENT_DYNCREATE(PPropertyValueArray, TObject); + +} -const TClass *PPropertyValue::TYPE_ARRAY = &TGetClass(PArray); -const TClass *PPropertyValue::TYPE_BOOL = &TGetClass(PBool); -const TClass *PPropertyValue::TYPE_FLOAT = &TGetClass(PFloat); -const TClass *PPropertyValue::TYPE_INT = &TGetClass(PInt); -const TClass *PPropertyValue::TYPE_PROPNAME = &TGetClass(PPropName); +const TClass *PPropertyValue::TYPE_INT = &TGetClass(ValueType::INT); +const TClass *PPropertyValue::TYPE_UINT32 = &TGetClass(ValueType::UINT32); +const TClass *PPropertyValue::TYPE_FLOAT = &TGetClass(ValueType::FLOAT); +const TClass *PPropertyValue::TYPE_BOOL = &TGetClass(ValueType::BOOL); +const TClass *PPropertyValue::TYPE_TPCSTRING = &TGetClass(ValueType::TPCString); +const TClass *PPropertyValue::TYPE_TPWSTRING = &TGetClass(ValueType::TPWString); +const TClass *PPropertyValue::TYPE_TLSTRING = &TGetClass(ValueType::TLString); +const TClass *PPropertyValue::TYPE_PROPNAME = &TGetClass(ValueType::PPropertyName); +const TClass *PPropertyValue::TYPE_ARRAY = &TGetClass(ValueType::PPropertyValueArray); const TClass *PPropertyValue::TYPE_PROPS = &TGetClass(PProperties); -const TClass *PPropertyValue::TYPE_TLSTRING = &TGetClass(PLString); -const TClass *PPropertyValue::TYPE_TPCSTRING = &TGetClass(PCString); -const TClass *PPropertyValue::TYPE_TPWSTRING = &TGetClass(PWString); -const TClass *PPropertyValue::TYPE_UINT32 = &TGetClass(PPUINT32); const TClass *PPropertyValue::TYPE_UNDEF = TNULL; PPropertyValue::PPropertyValue() @@ -108,6 +112,7 @@ PPropertyValue::PPropertyValue(const PPropertyName &a_rPropname) PPropertyValue::PPropertyValue(PProperties *props) { m_type = TYPE_PROPS; + m_valueProps = TNULL; GetPropertiesMP() = props; } @@ -178,9 +183,27 @@ TBOOL PPropertyValue::ChangeType(const TClass *a_pType) if (m_type == TYPE_TPCSTRING) { GetTPCString().~TPCString(); } + else if (m_type == TYPE_PROPS) { + GetPropertiesMP().~TManagedPtr(); + } + else if (m_type == TYPE_ARRAY) { + GetPropArrayMP().~TManagedPtr(); + } + else if (m_type == TYPE_PROPNAME) { + delete m_valueName; + } if (a_pType == TYPE_TPCSTRING) { m_valueInt = 0; } + else if (a_pType == TYPE_PROPS) { + m_valueProps = TNULL; + } + else if (a_pType == TYPE_ARRAY) { + m_valueArray = TNULL; + } + else if (a_pType == TYPE_PROPNAME) { + m_valueName = TNULL; + } // TODO implement all types m_type = a_pType; return TTRUE;