Math: Add serialization specialization for all types
Former-commit-id: 7e45c50d3b4eabfc581736f290fc208592d3d46c
This commit is contained in:
@@ -816,6 +816,56 @@ namespace Nz
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Serializes a Rect
|
||||
* \return true if successfully serialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param rect Input Rect
|
||||
*/
|
||||
template<typename T>
|
||||
bool Serialize(SerializationContext& context, const Rect<T>& rect)
|
||||
{
|
||||
if (!Serialize(context, rect.x))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, rect.y))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, rect.width))
|
||||
return false;
|
||||
|
||||
if (!Serialize(context, rect.height))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Unserializes a Rect
|
||||
* \return true if successfully unserialized
|
||||
*
|
||||
* \param context Serialization context
|
||||
* \param rect Output Rect
|
||||
*/
|
||||
template<typename T>
|
||||
bool Unserialize(SerializationContext& context, Rect<T>* rect)
|
||||
{
|
||||
if (!Unserialize(context, &rect->x))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &rect->y))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &rect->width))
|
||||
return false;
|
||||
|
||||
if (!Unserialize(context, &rect->height))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user