engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 友元 | 所有成员列表
FVariant类 参考

Implements an extensible union of multiple types. 更多...

#include <Variant.h>

Public 成员函数

void Empty ()
 Empties the value. 更多...
 
 FVariant ()
 Default constructor.
 
 FVariant (const TCHAR *InString)
 Creates and initializes a new instance from a TCHAR string. 更多...
 
template<typename T >
 FVariant (T InValue)
 Creates and initializes a new instance with the specified value. 更多...
 
 FVariant (TArray< uint8 > &&InArray)
 Creates and initializes a new instance from a byte array. 更多...
 
const TArray< uint8 > & GetBytes () const
 Gets the stored value as a byte array. 更多...
 
int32 GetSize () const
 Gets the stored value's size (in bytes). 更多...
 
EVariantTypes GetType () const
 Gets the stored value's type. 更多...
 
template<typename T >
T GetValue () const
 Gets the stored value. 更多...
 
template<>
FORCEINLINE TArray< uint8 > GetValue () const
 Gets the stored value for byte arrays. 更多...
 
bool IsEmpty () const
 Checks whether the value is empty. 更多...
 
template<typename T >
 operator T () const
 Implicit conversion operator. 更多...
 
bool operator!= (const FVariant &Other) const
 Comparison operator for inequality. 更多...
 
FVariant & operator= (const TCHAR *InString)
 Assignment operator for TCHAR strings. 更多...
 
template<typename T >
FVariant & operator= (T InValue)
 Assignment operator. 更多...
 
FVariant & operator= (TArray< uint8 > &&InArray)
 Assignment operator for byte arrays. 更多...
 
bool operator== (const FVariant &Other) const
 Comparison operator for equality. 更多...
 

友元

FArchive & operator<< (FArchive &Ar, FVariant &Variant)
 Serializes the given variant type from or into the specified archive. 更多...
 

详细描述

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.

构造及析构函数说明

◆ FVariant() [1/3]

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

Creates and initializes a new instance with the specified value.

参数
InValueThe initial value.

◆ FVariant() [2/3]

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.

参数
InValue-The initial value.

◆ FVariant() [3/3]

FVariant::FVariant ( const TCHAR *  InString)
inline

Creates and initializes a new instance from a TCHAR string.

参数
InStringThe initial value.

成员函数说明

◆ Empty()

void FVariant::Empty ( )
inline

Empties the value.

参见
IsEmpty

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

返回
Byte array.
参见
GetValue

◆ GetSize()

int32 FVariant::GetSize ( ) const
inline

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

返回
Size of the value.
参见
GetType, GetValue

◆ GetType()

EVariantTypes FVariant::GetType ( ) const
inline

Gets the stored value's type.

返回
Type of the value.
参见
GetSize, GetValue

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

返回
The value.
参见
GetSize, GetType

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

返回
The byte array.
参见
GetBytes

◆ IsEmpty()

bool FVariant::IsEmpty ( ) const
inline

Checks whether the value is empty.

返回
true if the value is empty, false otherwise.
参见
Empty

◆ operator T()

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

Implicit conversion operator.

参数
TThe type to convert the value to.
返回
The value converted to the specified type.

◆ operator!=()

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

Comparison operator for inequality.

参数
OtherThe variant to compare with.
返回
true if the values are not equal, false otherwise.

◆ operator=() [1/3]

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

Assignment operator for TCHAR strings.

参数
InStringThe value to assign.
返回
This instance.

◆ operator=() [2/3]

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

Assignment operator.

参数
TThe type of the value to assign.
InValueThe value to assign.
返回
This instance.

◆ operator=() [3/3]

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.

参数
InArrayThe byte array to assign.
返回
This instance.

◆ operator==()

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

Comparison operator for equality.

参数
OtherThe variant to compare with.
返回
true if the values are equal, false otherwise.

友元及相关函数文档

◆ operator<<

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

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

参数
ArThe archive to serialize from or into.
VariantThe value to serialize.
返回
The archive.

该类的文档由以下文件生成: