class ManagedSerializableFieldData

Inherits: IReflectable

Contains value of a single field in a managed object.

This class can contain any data type and should be overridden for specific types.

Stored values can be serialized and stored for later use, and deserialized back to managed objects when needed. You must call serialize() before performing RTTI serialization. After field data has been serialized you should not call any methods on it before calling deserialize().

Public

Methods

~ManagedSerializableFieldData

virtual ~ManagedSerializableFieldData() noexcept = default

staticCreate

static SPtr<ManagedSerializableFieldData> Create(const SPtr<ManagedTypeInfo> &typeInfo, MonoObject *value)

Creates a new data wrapper for some field data.

typeInfo
Type of the data we're storing.
value
Managed boxed value to store in the field. Value will be copied into the internal buffer and stored.

staticCreateDefault

static SPtr<ManagedSerializableFieldData> CreateDefault(const SPtr<ManagedTypeInfo> &typeInfo)

Creates a new data wrapper containing default instance of the provided type.

typeInfo
Type of the data we're storing.

GetValue

virtual void *GetValue(const SPtr<ManagedTypeInfo> &typeInfo) = 0

Returns the internal value.

typeInfo
Type of the data we're looking to retrieve. This isn't required for actually retrieving the data but is used as an extra check to ensure the field contains the data type we're looking for.

Returns: Pointer to the internal serialized data. Caller must ensure the pointer is cast to the proper type.

GetValueBoxed

virtual MonoObject *GetValueBoxed(const SPtr<ManagedTypeInfo> &typeInfo) = 0

Boxes the internal value and returns it.

typeInfo
Type of the data we're looking to retrieve. This isn't required for actually retrieving the data but is used as an extra check to ensure the field contains the data type we're looking for.

Returns: Boxed representation of the internal value.

Equals

virtual bool Equals(const SPtr<ManagedSerializableFieldData> &other, RTTIOperationContext *context = nullptr) = 0

Checks if the internal value stored in this object matches the value stored in another.

Does shallow comparison for complex objects.

GetHash

virtual size_t GetHash() = 0

Returns a hash value for the internally stored value.

Serialize

virtual void Serialize()

Serializes the internal value so that it may be stored and deserialized later.

Deserialize

virtual void Deserialize()

Deserializes the internal value so that the managed instance can be retrieved.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const

Returns an interface you can use to access class' Run Time Type Information.

Private

Methods

staticCreate

static SPtr<ManagedSerializableFieldData> Create(const SPtr<ManagedTypeInfo> &typeInfo, MonoObject *value, bool allowNull)

Creates a new data wrapper for some field data.

typeInfo
Type of the data we're storing.
value
Managed boxed value to store in the field. Value will be copied into the internal buffer and stored.
allowNull
Determines should null values be allowed. If false the objects with null values will instead be instantiated to their default values.