Apparatus Version 1.8
ECS data-oriented workflow for Unreal Engine.
Public Member Functions | List of all members
FScriptStructArray Struct Reference

Runtime-safe container for structs. More...

#include <ScriptStructArray.h>

Public Member Functions

UScriptStruct * GetElementType () const
 Get the type of the elements in the array. More...
 
int32 GetElementSize () const
 Get the size of a single element. More...
 
int32 Num () const
 Get the current number of elements in the array. More...
 
int32 Max () const
 Get the maximum number of elements that can be stored in the array without any additional allocations. More...
 
void * At (const int32 Index)
 Get an element data at specified index. More...
 
const void * At (const int32 Index) const
 Get an element data at specified index. More...
 
template<typename T >
T & RefAt (const int32 Index)
 Get an element reference at a specific index. More...
 
template<typename T >
const T & RefAt (const int32 Index) const
 Get an element reference at a specific index. More...
 
void * operator[] (const int32 Index)
 Get an element data at specified index. More...
 
const void * operator[] (const int32 Index) const
 Get a read-only element data at specified index. More...
 
bool Reserve (const int32 InCapacity)
 Reserve the space for a certain amount of elements. More...
 
void * AppendDefaulted ()
 Append a new struct element with default-initialized value. More...
 
void * AppendDefaulted (const int32 InCount)
 Append several new struct elements with default-initialized values. More...
 
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. More...
 
void Pop (const int32 InCount=1, const bool bAllowShrinking=true)
 Remove the elements from the end of the container. More...
 
void Set (UScriptStruct *const InElementType, const int32 InCapacity=0)
 Set the container with an element type and a capacity. More...
 
void Set (const FScriptStructArray &Array)
 
 FScriptStructArray ()
 
 FScriptStructArray (UScriptStruct *InElementType, int32 InCapacity=0)
 
 FScriptStructArray (const FScriptStructArray &Array)
 
 FScriptStructArray (FScriptStructArray &&Array)
 Construct with moving an array. More...
 
 ~FScriptStructArray ()
 
EApparatusStatus CopyElementTo (const int32 ElementIndex, void *const OutData, const bool bDataInitialized=true) const
 Copies an element at a specific index to a struct data. More...
 
template<typename T >
EApparatusStatus CopyElementTo (const int32 ElementIndex, T &OutStruct, const bool bStructInitialized=true) const
 Copies an element at a specific index to a struct. More...
 
template<typename T >
ElementAt (const int32 ElementIndex) const
 Gets a copy of an element at a specific index returning it to the caller. More...
 
void SetElementAt (const int32 ElementIndex, const void *const InData)
 Sets an element at a specific index to an initialized struct data. More...
 
void Swap (const int32 FirstIndexToSwap, const int32 SecondIndexToSwap)
 Swap two elements in the array. More...
 
void ClearElementAt (const int32 ElementIndex)
 Clear an element at a specific index by finalizing and initializing it again. More...
 
int32 CloneElementAt (const int32 ElementIndex)
 Clone an element at a specified index. More...
 
FScriptStructArrayoperator= (FScriptStructArray &&Array)
 Move an array. More...
 
FScriptStructArrayoperator= (const FScriptStructArray &Array)
 Set the array equal to an another one. More...
 

Detailed Description

Runtime-safe container for structs.

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.

◆ CopyElementTo() [1/2]

template<typename T >
EApparatusStatus FScriptStructArray::CopyElementTo ( 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.

◆ CopyElementTo() [2/2]

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

Copies 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.

◆ ElementAt()

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.

◆ 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 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?

◆ 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()

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

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

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

◆ Swap()

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

Swap two elements in the array.


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