Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FVariant Class Reference

#include <Variant.h>

+ Collaboration diagram for FVariant:

Public Member Functions

 FVariant ()
 
 FVariant (const FVariant &)=default
 
FVariantoperator= (const FVariant &)=default
 
 ~FVariant ()=default
 
 FVariant (FVariant &&Other)
 
FVariantoperator= (FVariant &&Other)
 
template<typename T >
 FVariant (T InValue)
 
 FVariant (TArray< uint8 > &&InArray)
 
 FVariant (const TArray< uint8 > &InArray)
 
 FVariant (const TCHAR *InString)
 
template<typename T >
FVariantoperator= (T InValue)
 
FVariantoperator= (TArray< uint8 > &&InArray)
 
FVariantoperator= (const TArray< uint8 > &InArray)
 
FVariantoperator= (const TCHAR *InString)
 
template<typename T >
 operator T () const
 
bool operator== (const FVariant &Other) const
 
bool operator!= (const FVariant &Other) const
 
void Empty ()
 
bool IsEmpty () const
 
const TArray< uint8 > & GetBytes () const
 
int32 GetSize () const
 
EVariantTypes GetType () const
 
template<typename T >
T GetValue () const
 
template<>
FORCEINLINE TArray< uint8GetValue () const
 

Private Attributes

EVariantTypes Type
 
TArray< uint8Value
 

Friends

FArchiveoperator<< (FArchive &Ar, FVariant &Variant)
 

Detailed Description

Implements an extensible union of multiple types.

Variant types can be used to store a range of different built-in types, as well as user defined types. The values are internally serialized into a byte array, which means that only FArchive serializable types are supported at this time.

Definition at line 113 of file Variant.h.

Constructor & Destructor Documentation

◆ FVariant() [1/7]

FVariant::FVariant ( )
inline

Default constructor.

Definition at line 118 of file Variant.h.

◆ FVariant() [2/7]

FVariant::FVariant ( const FVariant & )
default

◆ ~FVariant()

FVariant::~FVariant ( )
default

◆ FVariant() [3/7]

FVariant::FVariant ( FVariant && Other)
inline

Definition at line 126 of file Variant.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FVariant() [4/7]

template<typename T >
FVariant::FVariant ( T InValue)
inline

Creates and initializes a new instance with the specified value.

Parameters
InValueThe initial value.

Definition at line 150 of file Variant.h.

◆ FVariant() [5/7]

FVariant::FVariant ( TArray< uint8 > && InArray)
inline

Creates and initializes a new instance from a byte array.

Array values are passed straight through as an optimization. Please note that, if you serialize any complex types into arrays and then store them in FVariant, you will be responsible for ensuring byte ordering if the FVariant gets sent over the network.

Parameters
InValue-The initial value.

Definition at line 167 of file Variant.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FVariant() [6/7]

FVariant::FVariant ( const TArray< uint8 > & InArray)
inline

Definition at line 171 of file Variant.h.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ FVariant() [7/7]

FVariant::FVariant ( const TCHAR * InString)
inline

Creates and initializes a new instance from a TCHAR string.

Parameters
InStringThe initial value.

Definition at line 181 of file Variant.h.

+ Here is the call graph for this function:

Member Function Documentation

◆ Empty()

void FVariant::Empty ( )
inline

Empties the value.

See also
IsEmpty

Definition at line 288 of file Variant.h.

◆ GetBytes()

const TArray< uint8 > & FVariant::GetBytes ( ) const
inline

Gets the stored value as a byte array.

This method returns the internal representation of any value as an array of raw bytes. To retrieve values of type TArray<uint8> use GetValue<TArray<uint8>>() instead.

Returns
Byte array.
See also
GetValue

Definition at line 317 of file Variant.h.

◆ GetSize()

int32 FVariant::GetSize ( ) const
inline

Gets the stored value's size (in bytes).

Returns
Size of the value.
See also
GetType, GetValue

Definition at line 328 of file Variant.h.

◆ GetType()

EVariantTypes FVariant::GetType ( ) const
inline

Gets the stored value's type.

Returns
Type of the value.
See also
GetSize, GetValue

Definition at line 339 of file Variant.h.

◆ GetValue() [1/2]

template<typename T >
T FVariant::GetValue ( ) const
inline

Gets the stored value.

This template function does not provide any automatic conversion between convertible types. The exact type of the value to be extracted must be known.

Returns
The value.
See also
GetSize, GetType

Definition at line 354 of file Variant.h.

◆ GetValue() [2/2]

template<>
FORCEINLINE TArray< uint8 > FVariant::GetValue ( ) const

Gets the stored value for byte arrays.

Array values are passed straight through as an optimization. Please note that, if you serialize any complex types into arrays and then store them in FVariant, you will be responsible for ensuring byte ordering if the FVariant gets send over the network.

To retrieve any value as an array of serialized bytes, use GetBytes() instead.

Returns
The byte array.
See also
GetBytes

Definition at line 403 of file Variant.h.

◆ IsEmpty()

bool FVariant::IsEmpty ( ) const
inline

Checks whether the value is empty.

Returns
true if the value is empty, false otherwise.
See also
Empty

Definition at line 302 of file Variant.h.

◆ operator T()

template<typename T >
FVariant::operator T ( ) const
inline

Implicit conversion operator.

Parameters
TThe type to convert the value to.
Returns
The value converted to the specified type.

Definition at line 252 of file Variant.h.

◆ operator!=()

bool FVariant::operator!= ( const FVariant & Other) const
inline

Comparison operator for inequality.

Parameters
OtherThe variant to compare with.
Returns
true if the values are not equal, false otherwise.

Definition at line 276 of file Variant.h.

◆ operator=() [1/6]

FVariant & FVariant::operator= ( const FVariant & )
default

◆ operator=() [2/6]

FVariant & FVariant::operator= ( const TArray< uint8 > & InArray)
inline

Definition at line 223 of file Variant.h.

◆ operator=() [3/6]

FVariant & FVariant::operator= ( const TCHAR * InString)
inline

Assignment operator for TCHAR strings.

Parameters
InStringThe value to assign.
Returns
This instance.

Definition at line 237 of file Variant.h.

+ Here is the call graph for this function:

◆ operator=() [4/6]

FVariant & FVariant::operator= ( FVariant && Other)
inline

Definition at line 133 of file Variant.h.

◆ operator=() [5/6]

template<typename T >
FVariant & FVariant::operator= ( T InValue)
inline

Assignment operator.

Parameters
TThe type of the value to assign.
InValueThe value to assign.
Returns
This instance.

Definition at line 196 of file Variant.h.

◆ operator=() [6/6]

FVariant & FVariant::operator= ( TArray< uint8 > && InArray)
inline

Assignment operator for byte arrays.

Array values are passed straight through as an optimization. Please note that, if you serialize any complex types into arrays and then store them in FVariant, you will be responsible for ensuring byte ordering if the FVariant gets sent over the network.

Parameters
InArrayThe byte array to assign.
Returns
This instance.

Definition at line 216 of file Variant.h.

◆ operator==()

bool FVariant::operator== ( const FVariant & Other) const
inline

Comparison operator for equality.

Parameters
OtherThe variant to compare with.
Returns
true if the values are equal, false otherwise.

Definition at line 265 of file Variant.h.

Friends And Related Symbol Documentation

◆ operator<<

FArchive & operator<< ( FArchive & Ar,
FVariant & Variant )
friend

Serializes the given variant type from or into the specified archive.

Parameters
ArThe archive to serialize from or into.
VariantThe value to serialize.
Returns
The archive.

Definition at line 375 of file Variant.h.

Member Data Documentation

◆ Type

EVariantTypes FVariant::Type
private

Holds the type of the variant.

Definition at line 383 of file Variant.h.

◆ Value

TArray<uint8> FVariant::Value
private

Holds the serialized value.

Definition at line 386 of file Variant.h.


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