struct
TRTTIIteratorField
template<class ObjectRTTIType, class DataType, bool IsDataTypeContainer, class ObjectType>RTTI field type that supports iteration over arbitrary containers, including maps.
Unlike older field types, this field type internally handles plain, reflectable and reflectable pointer types, rather than requiring a separate field type for each. Also handles access to non-container elements by mimicing a single-element container.
Template parameters
ObjectRTTIType | RTTIType of the object that contains the field we're accessing. |
|---|---|
DataType | Type of the container being iterated over. |
IsDataTypeContainer | Set to true DataType is a container (e.g. vector, map) and you wish to iterate over it as such. If false, the iterator will act as faux iterator over a single element. |
ObjectType | Type of the object that the field is a member of. |
Public
Constructors
TRTTIIteratorField<ObjectRTTIType, DataType, IsDataTypeContainer, ObjectType>
Methods
InitSchema
Initializes the field's RTTI schema.
Should be called once after construction.
GetIterator
Returns the iterator that can be used for iterating all entries in the field.
IteratorSupportsSeekToIndex
Returns true if the iterator is allowed to seek to index.
True for iterators over arrays.
IteratorSupportsSeekToKey
Returns true if the iterator is allowed to seek to key.
True for iterators over sets and maps.
GetIteratorValue
Returns the current value of the iterator.
SetIteratorValue
Inserts a new value before the iterator location. must have been created by a call to CreateEmptyFieldValue() or GetIteratorValueCopy(), using the same .
CreateEmptyFieldValue
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().
GetIteratorValueCopy
Returns a modifiable copy of the current value of the iterator.
Returned value must be freed via FreeFieldValue() when done using it.
FreeFieldValue
Frees the field value created by CreateEmptyFieldValue() or GetIteratorValueCopy().
Same allocator must be provided as used for creating the field value.
ReadPlainTypeTupleFromStream
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
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
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
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
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
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
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.
~RTTIIteratorField
~RTTIField
CheckIsArray
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.