Fixes for serialization problems with custom structures
This commit is contained in:
@@ -345,6 +345,24 @@ namespace Serialization
|
||||
v.Deserialize(stream, modifier);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline typename TEnableIf<TIsBaseOf<ISerializable, T>::Value, bool>::Type ShouldSerialize(ISerializable& v, const void* otherObj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
template<typename T>
|
||||
inline typename TEnableIf<TIsBaseOf<ISerializable, T>::Value>::Type Serialize(ISerializable::SerializeStream& stream, ISerializable& v, const void* otherObj)
|
||||
{
|
||||
stream.StartObject();
|
||||
v.Serialize(stream, otherObj);
|
||||
stream.EndObject();
|
||||
}
|
||||
template<typename T>
|
||||
inline typename TEnableIf<TIsBaseOf<ISerializable, T>::Value>::Type Deserialize(ISerializable::DeserializeStream& stream, ISerializable& v, ISerializeModifier* modifier)
|
||||
{
|
||||
v.Deserialize(stream, modifier);
|
||||
}
|
||||
|
||||
// Scripting Object
|
||||
|
||||
template<typename T>
|
||||
@@ -460,7 +478,7 @@ namespace Serialization
|
||||
return true;
|
||||
for (int32 i = 0; i < v.Count(); i++)
|
||||
{
|
||||
if (ShouldSerialize(v[i], &other->At(i)))
|
||||
if (ShouldSerialize((T&)v[i], (const void*)&other->At(i)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -470,7 +488,7 @@ namespace Serialization
|
||||
{
|
||||
stream.StartArray();
|
||||
for (int32 i = 0; i < v.Count(); i++)
|
||||
Serialize(stream, v[i], nullptr);
|
||||
Serialize(stream, (T&)v[i], nullptr);
|
||||
stream.EndArray();
|
||||
}
|
||||
template<typename T, typename AllocationType = HeapAllocation>
|
||||
@@ -481,7 +499,7 @@ namespace Serialization
|
||||
const auto& streamArray = stream.GetArray();
|
||||
v.Resize(streamArray.Size());
|
||||
for (int32 i = 0; i < v.Count(); i++)
|
||||
Deserialize(streamArray[i], v[i], modifier);
|
||||
Deserialize(streamArray[i], (T&)v[i], modifier);
|
||||
}
|
||||
|
||||
// Dictionary
|
||||
@@ -496,7 +514,7 @@ namespace Serialization
|
||||
return true;
|
||||
for (auto& i : v)
|
||||
{
|
||||
if (!other->ContainsKey(i.Key) || ShouldSerialize(i.Value, &other->At(i.Key)))
|
||||
if (!other->ContainsKey(i.Key) || ShouldSerialize(i.Value, (const void*)&other->At(i.Key)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user