struct RTTIIteratorField

Inherits: RTTIField

Provides interface to be implemented by specializations of TRTTIIteratorField.

Public

Methods

~RTTIIteratorField

virtual ~RTTIIteratorField() noexcept = default

GetIterator

virtual SPtr<IRTTIIterator> GetIterator(RTTIType *rttiTypeInstance, void *object, FrameAllocator &frameAllocator) const = 0

Returns the iterator that can be used for iterating all entries in the field.

IteratorSupportsSeekToIndex

virtual bool IteratorSupportsSeekToIndex() const = 0

Returns true if the iterator is allowed to seek to index.

True for iterators over arrays.

IteratorSupportsSeekToKey

virtual bool IteratorSupportsSeekToKey() const = 0

Returns true if the iterator is allowed to seek to key.

True for iterators over sets and maps.

GetIteratorValue

virtual const void *GetIteratorValue(RTTIType *rttiTypeInstance, void *object, FrameAllocator &frameAllocator, IRTTIIterator &iterator) const = 0

Returns the current value of the iterator.

GetIteratorValueCopy

virtual void *GetIteratorValueCopy(RTTIType *rttiTypeInstance, void *object, FrameAllocator &frameAllocator, IRTTIIterator &iterator) const = 0

Returns a modifiable copy of the current value of the iterator.

Returned value must be freed via FreeFieldValue() when done using it.

SetIteratorValue

virtual void SetIteratorValue(RTTIType *rttiTypeInstance, void *object, FrameAllocator &frameAllocator, IRTTIIterator &iterator, void *value) = 0

Inserts a new value before the iterator location. must have been created by a call to CreateEmptyFieldValue() or GetIteratorValueCopy(), using the same .

CreateEmptyFieldValue

virtual void *CreateEmptyFieldValue(FrameAllocator &frameAllocator) = 0

Creates a new empty field value.

This should be populated by calls to WritePlainTypeTupleToStream(), SetReflectablePointer() or SetReflectable(), then passed to SetIteratorValue(), and finally freed via FreeFieldValue().

FreeFieldValue

virtual void FreeFieldValue(void *fieldValue, FrameAllocator &frameAllocator) = 0

Frees the field value created by CreateEmptyFieldValue() or GetIteratorValueCopy().

Same allocator must be provided as used for creating the field value.

ReadPlainTypeTupleFromStream

virtual void ReadPlainTypeTupleFromStream(void *fieldValue, u32 tupleElementIndex, Bitstream &stream, bool useCompression) = 0

Reads into the provided field value from the stream.

If the field value represents a tuple (i.e. contains multiple sub-types, such as std::pair

<K

, V>), this reads just a single tuple element, as specified by .

fieldValue
Field value to read into, as created by CreateEmptyFieldValue().
tupleElementIndex
Index of the tuple element in to read into. If doesn't represent a tuple, this should be 0.
stream
Stream from which to read from.
useCompression
If true, values will read as compressed where relevant. Must be set of the value was written with compression enabled.

WritePlainTypeTupleToStream

virtual void WritePlainTypeTupleToStream(const void *fieldValue, u32 tupleElementIndex, Bitstream &stream, bool useCompression) = 0

Writes the provided field value to the stream.

If the field value represents a tuple (i.e. contains multiple sub-types, such as std::pair

<K

, V>), this encodes just a single tuple element, as specified by .

fieldValue
Field value to write, as returned by GetIteratorValue().
tupleElementIndex
Index of the tuple element in to write. If doesn't represent a tuple, this should be 0.
stream
Stream in which to write to.
useCompression
If true, values will attempt to be compressed where relevant. Must be decoded with this flag in the same state.

SetReflectablePointer

virtual void SetReflectablePointer(void *fieldValue, u32 tupleElementIndex, const SPtr<IReflectable> &reflectable) = 0

Assigns the reflectable pointer to the provided field value.

If the field value represents a tuple (i.e. contains multiple sub-types, such as std::pair

<K

, V>), this assigns a single element of the tuple, as specified by . If the field value is not a tuple, is simply assigned to .

fieldValue
Field value in which to store the reflectable pointer, as created by CreateEmptyFieldValue().
tupleElementIndex
Index of the tuple element in in which to store the reflectable pointer. If doesn't represent a tuple, this should be 0.
reflectable
Reflectable pointer to assign to the field value.

GetReflectablePointer

virtual SPtr<IReflectable> GetReflectablePointer(const void *fieldValue, u32 tupleElementIndex) = 0

Reads the reflectable pointer from the provided field value.

If the field value represents a tuple (i.e. contains multiple sub-types, such as std::pair

<K

, V>), this reads a single element of the tuple, as specified by . If the field value is not a tuple, is simply cast to a reflectable pointer type.

fieldValue
Field value containing the reflectable pointer, as returned by GetIteratorValue().
tupleElementIndex
Index of the tuple element in which contains the reflectable pointer. If doesn't represent a tuple, this should be 0.

Returns: Reflectable pointer.

SetReflectable

virtual void SetReflectable(void *fieldValue, u32 tupleElementIndex, const IReflectable &reflectable) = 0

Assigns the reflectable to the provided field value.

If the field value represents a tuple (i.e. contains multiple sub-types, such as std::pair

<K

, V>), this assigns a single element of the tuple, as specified by . If the field value is not a tuple, is simply assigned to .

fieldValue
Field value in which to store the reflectable, as created by CreateEmptyFieldValue().
tupleElementIndex
Index of the tuple element in in which to store the reflectable. If doesn't represent a tuple, this should be 0.
reflectable
Reflectable to assign to the field value.

GetReflectable

virtual const IReflectable &GetReflectable(const void *fieldValue, u32 tupleElementIndex) = 0

Reads the reflectable value from the provided field value.

If the field value represents a tuple (i.e. contains multiple sub-types, such as std::pair

<K

, V>), this reads a single element of the tuple, as specified by . If the field value is not a tuple, is simply cast to a reflectable type.

fieldValue
Field value containing the reflectable, as returned by GetIteratorValue().
tupleElementIndex
Index of the tuple element in which contains the reflectable. If doesn't represent a tuple, this should be 0.

Returns: Reflectable.

GetPlainTypeSize

virtual BitLength GetPlainTypeSize(const void *fieldValue, u32 tupleElementIndex, bool useCompression) = 0

Returns the size of the plain type in the provided field value.

If the field value represents a tuple (i.e. contains multiple sub-types, such as std::pair

<K

, V>), this returns the size of just a single tuple element, as specified by .

fieldValue
Field value to retrieve size from, as returned by GetIteratorValue().
tupleElementIndex
Index of the tuple element in to retrieve size for. If doesn't represent a tuple, this should be 0.
useCompression
If true, size will be compressed if possible.

~RTTIField

virtual ~RTTIField() noexcept = default

InitSchema

virtual void InitSchema()

Initializes the field's RTTI schema.

Should be called once after construction.

CheckIsArray

void CheckIsArray(bool array) const

Throws an exception depending if the field is or isn't an array.

array
If true, then exception will be thrown if field is not an array. If false, then it will be thrown if field is an array.

Fields

Name

String Name

Schema

Protected

Methods

Init

void Init(String name, const RTTIFieldSchema &schema)