Apparatus Version 1.23
ECS data-oriented workflow for Unreal Engine.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
FScriptStructArray Struct Reference

Dynamically-typed container of structs. More...

#include <ScriptStructArray.h>

Public Types

enum  EGatheringType { Clear , Collect }
 The type of gathering to use during the collection. More...
 

Public Member Functions

UScriptStruct * GetElementType () const
 Get the type of the elements in the array.
 
int32 GetElementSize () const
 Get the size of a single element.
 
int32 Num () const
 Get the current number of elements currently in the array.
 
int32 Max () const
 Get the maximum number of elements that can be stored in the array without any additional allocations.
 
void * At (const int32 Index)
 Get an element data at specified index.
 
const void * At (const int32 Index) const
 Get an element data at specified index.
 
template<typename T >
TRefAt (const int32 Index)
 Get an element reference at a specific index.
 
template<typename T >
const TRefAt (const int32 Index) const
 Get an element reference at a specific index.
 
template<typename T >
TPtrAt (const int32 Index)
 Get an element reference at a specific index.
 
template<typename T >
const TPtrAt (const int32 Index) const
 Get an element reference at a specific index.
 
void * operator[] (const int32 Index)
 Get an element data at specified index.
 
const void * operator[] (const int32 Index) const
 Get a read-only element data at specified index.
 
bool Reserve (const int32 InCapacity)
 Reserve the space for a certain amount of elements.
 
void * AppendDefaulted ()
 Append a new struct element with default-initialized value.
 
void * AppendDefaulted (const int32 InCount)
 Append several new struct elements with default-initialized values.
 
void Reset (const int32 InCapacity=0)
 Clear the array without changing the allocated space, but only if the passed capacity is not larger than the present one.
 
void Pop (const int32 InCount=1, const bool bAllowShrinking=true)
 Remove the elements from the end of the container.
 
void Set (UScriptStruct *const InElementType, const int32 InCapacity=0)
 Set the container with an element type and a capacity.
 
void Set (const FScriptStructArray &Array)
 
 FScriptStructArray ()
 
 FScriptStructArray (UScriptStruct *InElementType, int32 InCapacity=0)
 
 FScriptStructArray (const FScriptStructArray &Array)
 
 FScriptStructArray (FScriptStructArray &&Array)
 Construct with moving an array.
 
 ~FScriptStructArray ()
 
EApparatusStatus ElementAt (const int32 ElementIndex, void *const OutData, const bool bDataInitialized=true) const
 Copy an element at a specific index to a struct data.
 
EApparatusStatus SwapElementWith (const int32 ElementIndex, void *const OtherData, const bool bDataInitialized=true)
 Swap an element at a specific index to a struct data.
 
template<typename T >
EApparatusStatus ElementAt (const int32 ElementIndex, T &OutStruct, const bool bStructInitialized=true) const
 Copies an element at a specific index to a struct.
 
template<typename T , typename AllocatorT >
EApparatusStatus CopyTo (TArray< T, AllocatorT > &OutArray, const EGatheringType GatheringType=Clear) const
 Copy the elements of the array to a normal array.
 
template<typename T >
T ElementAt (const int32 ElementIndex) const
 Gets a copy of an element at a specific index returning it to the caller.
 
EApparatusStatus SetElementAt (const int32 ElementIndex, const void *const InData)
 Sets an element at a specific index to an initialized struct data.
 
template<typename T >
EApparatusStatus SetElementAt (const int32 ElementIndex, const T &InElement)
 Sets an element at a specific index to an initialized struct data.
 
template<typename T >
EApparatusStatus SetElementAt (const int32 ElementIndex, const T *const InElement)
 Sets an element at a specific index to an initialized struct data.
 
void Swap (const int32 FirstIndexToSwap, const int32 SecondIndexToSwap)
 Swap two elements in the array.
 
void ClearElementAt (const int32 ElementIndex)
 Clear an element at a specific index by finalizing and initializing it again.
 
int32 CloneElementAt (const int32 ElementIndex)
 Clone an element at a specified index.
 
FScriptStructArrayoperator= (FScriptStructArray &&Array)
 Move an array.
 
FScriptStructArrayoperator= (const FScriptStructArray &Array)
 Set the array equal to an another one.
 

Detailed Description

Dynamically-typed container of structs.

Unlike TArray<T> which is statically (compile-time) typed you can use this container with a runtime-defined struct type to store an array of those.

Member Enumeration Documentation

◆ EGatheringType

The type of gathering to use during the collection.

Enumerator
Clear 

Clear the output buffer before collecting.

Collect 

Append to the existing elements of the outputting buffer.

Constructor & Destructor Documentation

◆ FScriptStructArray() [1/4]

FScriptStructArray::FScriptStructArray ( )
inline

◆ FScriptStructArray() [2/4]

FScriptStructArray::FScriptStructArray ( UScriptStruct *  InElementType,
int32  InCapacity = 0 
)
inline

◆ FScriptStructArray() [3/4]

FScriptStructArray::FScriptStructArray ( const FScriptStructArray Array)
inline

◆ FScriptStructArray() [4/4]

FScriptStructArray::FScriptStructArray ( FScriptStructArray &&  Array)
inline

Construct with moving an array.

◆ ~FScriptStructArray()

FScriptStructArray::~FScriptStructArray ( )
inline

Member Function Documentation

◆ AppendDefaulted() [1/2]

void * FScriptStructArray::AppendDefaulted ( )
inline

Append a new struct element with default-initialized value.

Returns
A pointer to the data of the added element.

◆ AppendDefaulted() [2/2]

void * FScriptStructArray::AppendDefaulted ( const int32  InCount)
inline

Append several new struct elements with default-initialized values.

Parameters
InCountThe total number of elements to append.
Returns
A pointer to the data of the first added element.

◆ At() [1/2]

void * FScriptStructArray::At ( const int32  Index)
inline

Get an element data at specified index.

Parameters
IndexThe index of an element to get the data of.
Returns
The initialized data of the element struct.

◆ At() [2/2]

const void * FScriptStructArray::At ( const int32  Index) const
inline

Get an element data at specified index.

Constant version.

Parameters
IndexThe index of an element to get the data of.
Returns
The initialized data of the element struct.

◆ ClearElementAt()

void FScriptStructArray::ClearElementAt ( const int32  ElementIndex)
inline

Clear an element at a specific index by finalizing and initializing it again.

Parameters
ElementIndexThe index of an element to clear.

◆ CloneElementAt()

int32 FScriptStructArray::CloneElementAt ( const int32  ElementIndex)
inline

Clone an element at a specified index.

Parameters
ElementIndexThe index of an element to clone.
Returns
The index of the newly added element.

◆ CopyTo()

template<typename T , typename AllocatorT >
EApparatusStatus FScriptStructArray::CopyTo ( TArray< T, AllocatorT > &  OutArray,
const EGatheringType  GatheringType = Clear 
) const
inline

Copy the elements of the array to a normal array.

Template Parameters
TThe type of elements of the array. Must match the current element type.
AllocatorTThe allocator used within an array.
Parameters
OutArrayThe array to output the structs to.
GatheringTypeThe type of gathering to apply.
Returns
The status of the operation.

◆ ElementAt() [1/3]

template<typename T >
T FScriptStructArray::ElementAt ( const int32  ElementIndex) const
inline

Gets a copy of an element at a specific index returning it to the caller.

Template Parameters
TThe type of the element to copy. Must match the type of the array elements.
Parameters
ElementIndexThe index of an element to copy.
Returns
The copy of the element.

◆ ElementAt() [2/3]

template<typename T >
EApparatusStatus FScriptStructArray::ElementAt ( const int32  ElementIndex,
T OutStruct,
const bool  bStructInitialized = true 
) const
inline

Copies an element at a specific index to a struct.

Templated version.

Template Parameters
TThe type of the element to copy. Must match the type of the array elements.
Parameters
ElementIndexThe index of an element to copy.
OutStructA receiving struct.
bStructInitializedIs the receiving struct actually initialized?
Returns
The status of the operation.

◆ ElementAt() [3/3]

EApparatusStatus FScriptStructArray::ElementAt ( const int32  ElementIndex,
void *const  OutData,
const bool  bDataInitialized = true 
) const
inline

Copy an element at a specific index to a struct data.

Parameters
ElementIndexThe index of an element to copy.
OutDataA receiving struct data pointer. Must have enough allocated space.
bDataInitializedIs the receiving data actually initialized?
Returns
The status of the operation.

◆ GetElementSize()

int32 FScriptStructArray::GetElementSize ( ) const
inline

Get the size of a single element.

Returns
The size of the element in bytes.

◆ GetElementType()

UScriptStruct * FScriptStructArray::GetElementType ( ) const
inline

Get the type of the elements in the array.

◆ Max()

int32 FScriptStructArray::Max ( ) const
inline

Get the maximum number of elements that can be stored in the array without any additional allocations.

◆ Num()

int32 FScriptStructArray::Num ( ) const
inline

Get the current number of elements currently in the array.

◆ operator=() [1/2]

FScriptStructArray & FScriptStructArray::operator= ( const FScriptStructArray Array)
inline

Set the array equal to an another one.

Parameters
ArrayAn array to copy.
Returns
Returns itself.

◆ operator=() [2/2]

FScriptStructArray & FScriptStructArray::operator= ( FScriptStructArray &&  Array)
inline

Move an array.

◆ operator[]() [1/2]

void * FScriptStructArray::operator[] ( const int32  Index)
inline

Get an element data at specified index.

Parameters
IndexThe index of an element to get the data of.
Returns
The initialized data of the element struct.

◆ operator[]() [2/2]

const void * FScriptStructArray::operator[] ( const int32  Index) const
inline

Get a read-only element data at specified index.

Parameters
IndexThe index of an element to get the data of.
Returns
The read-only initialized data of the element struct.

◆ Pop()

void FScriptStructArray::Pop ( const int32  InCount = 1,
const bool  bAllowShrinking = true 
)
inline

Remove the elements from the end of the container.

Parameters
InCountThe number of elements to remove.
bAllowShrinkingIs capacity shrinking allowed?

◆ PtrAt() [1/2]

template<typename T >
T * FScriptStructArray::PtrAt ( const int32  Index)
inline

Get an element reference at a specific index.

Template Parameters
TThe type of the element to cast to. Used for extra safety.
Parameters
IndexThe index of an element to get the data of.
Returns
The initialized data of the element struct.

◆ PtrAt() [2/2]

template<typename T >
const T * FScriptStructArray::PtrAt ( const int32  Index) const
inline

Get an element reference at a specific index.

Constant version.

Template Parameters
TThe type of the element to cast to. Used for extra safety.
Parameters
IndexThe index of an element to get the data of.
Returns
The initialized data of the element struct.

◆ RefAt() [1/2]

template<typename T >
T & FScriptStructArray::RefAt ( const int32  Index)
inline

Get an element reference at a specific index.

Template Parameters
TThe type of the element to cast to. Used for extra safety.
Parameters
IndexThe index of an element to get the data of.
Returns
The initialized data of the element struct.

◆ RefAt() [2/2]

template<typename T >
const T & FScriptStructArray::RefAt ( const int32  Index) const
inline

Get an element reference at a specific index.

Constant version.

Template Parameters
TThe type of the element to cast to. Used for extra safety.
Parameters
IndexThe index of an element to get the data of.
Returns
The initialized data of the element struct.

◆ Reserve()

bool FScriptStructArray::Reserve ( const int32  InCapacity)
inline

Reserve the space for a certain amount of elements.

Parameters
InCapacityThe new capacity to guarantee.
Returns
Was anything actually changed?

◆ Reset()

void FScriptStructArray::Reset ( const int32  InCapacity = 0)
inline

Clear the array without changing the allocated space, but only if the passed capacity is not larger than the present one.

Parameters
InCapacityThe new capacity to guarantee.

◆ Set() [1/2]

void FScriptStructArray::Set ( const FScriptStructArray Array)
inline

◆ Set() [2/2]

void FScriptStructArray::Set ( UScriptStruct *const  InElementType,
const int32  InCapacity = 0 
)
inline

Set the container with an element type and a capacity.

Parameters
InElementTypeThe new element type.
InCapacityThe new capacity to guarantee.

◆ SetElementAt() [1/3]

template<typename T >
EApparatusStatus FScriptStructArray::SetElementAt ( const int32  ElementIndex,
const T InElement 
)
inline

Sets an element at a specific index to an initialized struct data.

Template Parameters
TThe type of the element to set. Must match the element type of the array.
Parameters
[in]ElementIndexThe index of an element to set.
[in]InElementAn initialized struct data to set with.
Returns
The status of the operation.

◆ SetElementAt() [2/3]

template<typename T >
EApparatusStatus FScriptStructArray::SetElementAt ( const int32  ElementIndex,
const T *const  InElement 
)
inline

Sets an element at a specific index to an initialized struct data.

Template Parameters
TThe type of the element to set. Must match the element type of the array.
Parameters
[in]ElementIndexThe index of an element to set.
[in]InElementAn initialized struct data to set with.
Returns
The status of the operation.

◆ SetElementAt() [3/3]

EApparatusStatus FScriptStructArray::SetElementAt ( const int32  ElementIndex,
const void *const  InData 
)
inline

Sets an element at a specific index to an initialized struct data.

Parameters
[in]ElementIndexThe index of an element to set.
[in]InDataAn initialized struct data to set with.

◆ Swap()

void FScriptStructArray::Swap ( const int32  FirstIndexToSwap,
const int32  SecondIndexToSwap 
)
inline

Swap two elements in the array.

◆ SwapElementWith()

EApparatusStatus FScriptStructArray::SwapElementWith ( const int32  ElementIndex,
void *const  OtherData,
const bool  bDataInitialized = true 
)
inline

Swap an element at a specific index to a struct data.

Parameters
ElementIndexThe index of the element to swap.
OtherDataThe other struct data pointer. Must have enough allocated space.
bDataInitializedIs the receiving data actually initialized?
Returns
The status of the operation.

The documentation for this struct was generated from the following file: