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

#include <CompactBinary.h>

+ Inheritance diagram for FCbFieldView:

Public Member Functions

constexpr FCbFieldView ()=default
 
 FCbFieldView (const void *Data, ECbFieldType Type=ECbFieldType::HasFieldType)
 
 FCbFieldView (const FCbValue &Value)
 
constexpr FCbFieldView RemoveName () const
 
constexpr FUtf8StringView GetName () const
 
FCbValue GetValue () const
 
FCbObjectView AsObjectView ()
 
FCbArrayView AsArrayView ()
 
FMemoryView AsBinaryView (FMemoryView Default=FMemoryView())
 
FUtf8StringView AsString (FUtf8StringView Default=FUtf8StringView())
 
int8 AsInt8 (int8 Default=0)
 
int16 AsInt16 (int16 Default=0)
 
int32 AsInt32 (int32 Default=0)
 
int64 AsInt64 (int64 Default=0)
 
uint8 AsUInt8 (uint8 Default=0)
 
uint16 AsUInt16 (uint16 Default=0)
 
uint32 AsUInt32 (uint32 Default=0)
 
uint64 AsUInt64 (uint64 Default=0)
 
float AsFloat (float Default=0.0f)
 
double AsDouble (double Default=0.0)
 
bool AsBool (bool bDefault=false)
 
FIoHash AsObjectAttachment (const FIoHash &Default=FIoHash())
 
FIoHash AsBinaryAttachment (const FIoHash &Default=FIoHash())
 
FIoHash AsAttachment (const FIoHash &Default=FIoHash())
 
FIoHash AsHash (const FIoHash &Default=FIoHash())
 
FGuid AsUuid ()
 
FGuid AsUuid (const FGuid &Default)
 
int64 AsDateTimeTicks (int64 Default=0)
 
FDateTime AsDateTime ()
 
FDateTime AsDateTime (FDateTime Default)
 
int64 AsTimeSpanTicks (int64 Default=0)
 
FTimespan AsTimeSpan ()
 
FTimespan AsTimeSpan (FTimespan Default)
 
FCbObjectId AsObjectId (const FCbObjectId &Default=FCbObjectId())
 
FCbCustomById AsCustomById (FCbCustomById Default=FCbCustomById())
 
FCbCustomByName AsCustomByName (FCbCustomByName Default=FCbCustomByName())
 
FMemoryView AsCustom (uint64 Id, FMemoryView Default=FMemoryView())
 
FMemoryView AsCustom (FUtf8StringView Name, FMemoryView Default=FMemoryView())
 
constexpr bool HasName () const
 
constexpr bool IsNull () const
 
constexpr bool IsObject () const
 
constexpr bool IsArray () const
 
constexpr bool IsBinary () const
 
constexpr bool IsString () const
 
constexpr bool IsInteger () const
 
constexpr bool IsFloat () const
 
constexpr bool IsBool () const
 
constexpr bool IsObjectAttachment () const
 
constexpr bool IsBinaryAttachment () const
 
constexpr bool IsAttachment () const
 
constexpr bool IsHash () const
 
constexpr bool IsUuid () const
 
constexpr bool IsDateTime () const
 
constexpr bool IsTimeSpan () const
 
constexpr bool IsObjectId () const
 
constexpr bool IsCustomById () const
 
constexpr bool IsCustomByName () const
 
constexpr operator bool () const
 
constexpr bool HasValue () const
 
constexpr bool HasError () const
 
constexpr ECbFieldError GetError () const
 
uint64 GetSize () const
 
FIoHash GetHash () const
 
void AppendHash (FIoHashBuilder &Builder) const
 
bool Equals (const FCbFieldView &Other) const
 
void CopyTo (FMutableMemoryView Buffer) const
 
void CopyTo (FArchive &Ar) const
 
void IterateAttachments (FCbFieldVisitor Visitor) const
 
bool TryGetView (FMemoryView &OutView) const
 
FCbFieldView operator[] (FUtf8StringView Name) const
 
FCbFieldViewIterator CreateViewIterator () const
 
FCbFieldViewIterator begin () const
 
constexpr FCbIteratorSentinel end () const
 

Protected Member Functions

FMemoryView GetView () const
 
FMemoryView GetViewNoType () const
 
FMemoryView GetValueView () const
 
constexpr ECbFieldType GetType () const
 
constexpr ECbFieldType GetTypeWithFlags () const
 
constexpr const voidGetValueData () const
 
const voidGetValueEnd () const
 
uint64 GetValueSize () const
 
void Assign (const void *InData, const ECbFieldType InType)
 

Private Member Functions

template<typename IntType >
IntType AsInteger (IntType Default)
 
uint64 AsInteger (uint64 Default, UE::CompactBinary::Private::FIntegerParams Params)
 

Private Attributes

ECbFieldType TypeWithFlags = ECbFieldType::None
 
ECbFieldError Error = ECbFieldError::None
 
uint32 NameLen = 0
 
const voidValue = nullptr
 

Detailed Description

An atom of data in the compact binary format.

Accessing the value of a field is always a safe operation, even if accessed as the wrong type. An invalid access will return a default value for the requested type, and set an error code on the field that can be checked with GetLastError and HasLastError. A valid access will clear an error from a previous invalid access.

A field is encoded in one or more bytes, depending on its type and the type of object or array that contains it. A field of an object or array which is non-uniform encodes its field type in the first byte, and includes the HasFieldName flag for a field in an object. The field name is encoded in a variable-length unsigned integer of its size in bytes, for named fields, followed by that many bytes of the UTF-8 encoding of the name with no null terminator. The remainder of the field is the value which is described in the field type enum. Every field must be uniquely addressable when encoded, which means a zero-byte field is not permitted, and only arises in a uniform array of fields with no value, where the answer is to encode as a non-uniform array.

This type only provides a view into memory and does not perform any memory management itself. Use FCbField to hold a reference to the underlying memory when necessary.

Definition at line 606 of file CompactBinary.h.

Constructor & Destructor Documentation

◆ FCbFieldView() [1/3]

constexpr FCbFieldView::FCbFieldView ( )
constexprdefault

Construct a field with no name and no value.

◆ FCbFieldView() [2/3]

FCbFieldView::FCbFieldView ( const void * Data,
ECbFieldType Type = ECbFieldType::HasFieldType )
explicit

Construct a field from a pointer to its data and an optional externally-provided type.

Parameters
DataPointer to the start of the field data.
TypeHasFieldType means that Data contains the type. Otherwise, use the given type.

◆ FCbFieldView() [3/3]

FORCEINLINE FCbFieldView::FCbFieldView ( const FCbValue & Value)
inlineexplicit

Construct a field from a value, without access to the name.

Definition at line 72 of file CompactBinaryValue.h.

+ Here is the call graph for this function:

Member Function Documentation

◆ AppendHash()

void FCbFieldView::AppendHash ( FIoHashBuilder & Builder) const

Append the hash of the field, including the type and name.

◆ AsArrayView()

FCbArrayView FCbFieldView::AsArrayView ( )

Access the field as an array. Defaults to an empty array on error.

◆ AsAttachment()

FIoHash FCbFieldView::AsAttachment ( const FIoHash & Default = FIoHash())

Access the field as a hash referencing an attachment. Returns the provided default on error.

◆ AsBinaryAttachment()

FIoHash FCbFieldView::AsBinaryAttachment ( const FIoHash & Default = FIoHash())

Access the field as a hash referencing a binary attachment. Returns the provided default on error.

◆ AsBinaryView()

FMemoryView FCbFieldView::AsBinaryView ( FMemoryView Default = FMemoryView())

Access the field as binary. Returns the provided default on error.

◆ AsBool()

bool FCbFieldView::AsBool ( bool bDefault = false)

Access the field as a bool. Returns the provided default on error.

+ Here is the caller graph for this function:

◆ AsCustom() [1/2]

FMemoryView FCbFieldView::AsCustom ( FUtf8StringView Name,
FMemoryView Default = FMemoryView() )

Access the field as a custom sub-type with a string identifier. Returns the provided default on error.

◆ AsCustom() [2/2]

FMemoryView FCbFieldView::AsCustom ( uint64 Id,
FMemoryView Default = FMemoryView() )

Access the field as a custom sub-type with an integer identifier. Returns the provided default on error.

◆ AsCustomById()

FCbCustomById FCbFieldView::AsCustomById ( FCbCustomById Default = FCbCustomById())

Access the field as a custom sub-type with an integer identifier. Returns the provided default on error.

◆ AsCustomByName()

FCbCustomByName FCbFieldView::AsCustomByName ( FCbCustomByName Default = FCbCustomByName())

Access the field as a custom sub-type with a string identifier. Returns the provided default on error.

◆ AsDateTime() [1/2]

FDateTime FCbFieldView::AsDateTime ( )

Access the field as a date/time. Returns a date/time at the epoch on error.

◆ AsDateTime() [2/2]

FDateTime FCbFieldView::AsDateTime ( FDateTime Default)

Access the field as a date/time. Returns the provided default on error.

◆ AsDateTimeTicks()

int64 FCbFieldView::AsDateTimeTicks ( int64 Default = 0)

Access the field as a date/time tick count. Returns the provided default on error.

◆ AsDouble()

double FCbFieldView::AsDouble ( double Default = 0.0)

Access the field as a double. Returns the provided default on error.

+ Here is the caller graph for this function:

◆ AsFloat()

float FCbFieldView::AsFloat ( float Default = 0.0f)

Access the field as a float. Returns the provided default on error.

+ Here is the caller graph for this function:

◆ AsHash()

FIoHash FCbFieldView::AsHash ( const FIoHash & Default = FIoHash())

Access the field as a hash. Returns the provided default on error.

◆ AsInt16()

int16 FCbFieldView::AsInt16 ( int16 Default = 0)
inline

Access the field as an int16. Returns the provided default on error.

Definition at line 656 of file CompactBinary.h.

+ Here is the caller graph for this function:

◆ AsInt32()

int32 FCbFieldView::AsInt32 ( int32 Default = 0)
inline

Access the field as an int32. Returns the provided default on error.

Definition at line 658 of file CompactBinary.h.

+ Here is the caller graph for this function:

◆ AsInt64()

int64 FCbFieldView::AsInt64 ( int64 Default = 0)
inline

Access the field as an int64. Returns the provided default on error.

Definition at line 660 of file CompactBinary.h.

+ Here is the caller graph for this function:

◆ AsInt8()

int8 FCbFieldView::AsInt8 ( int8 Default = 0)
inline

Access the field as an int8. Returns the provided default on error.

Definition at line 654 of file CompactBinary.h.

+ Here is the caller graph for this function:

◆ AsInteger() [1/2]

template<typename IntType >
IntType FCbFieldView::AsInteger ( IntType Default)
inlineprivate

Access the field as the given integer type.

Returns the provided default if the value cannot be represented in the output type.

Definition at line 865 of file CompactBinary.h.

◆ AsInteger() [2/2]

uint64 FCbFieldView::AsInteger ( uint64 Default,
UE::CompactBinary::Private::FIntegerParams Params )
private

◆ AsObjectAttachment()

FIoHash FCbFieldView::AsObjectAttachment ( const FIoHash & Default = FIoHash())

Access the field as a hash referencing an object attachment. Returns the provided default on error.

◆ AsObjectId()

FCbObjectId FCbFieldView::AsObjectId ( const FCbObjectId & Default = FCbObjectId())

Access the field as an object identifier. Returns the provided default on error.

+ Here is the caller graph for this function:

◆ AsObjectView()

FCbObjectView FCbFieldView::AsObjectView ( )

Access the field as an object. Defaults to an empty object on error.

◆ Assign()

void FCbFieldView::Assign ( const void * InData,
const ECbFieldType InType )
inlineprotected

Assign a field from a pointer to its data and an optional externally-provided type.

Definition at line 851 of file CompactBinary.h.

◆ AsString()

FUtf8StringView FCbFieldView::AsString ( FUtf8StringView Default = FUtf8StringView())

Access the field as a string. Returns the provided default on error.

◆ AsTimeSpan() [1/2]

FTimespan FCbFieldView::AsTimeSpan ( )

Access the field as a timespan. Returns an empty timespan on error.

◆ AsTimeSpan() [2/2]

FTimespan FCbFieldView::AsTimeSpan ( FTimespan Default)

Access the field as a timespan. Returns the provided default on error.

◆ AsTimeSpanTicks()

int64 FCbFieldView::AsTimeSpanTicks ( int64 Default = 0)

Access the field as a timespan tick count. Returns the provided default on error.

◆ AsUInt16()

uint16 FCbFieldView::AsUInt16 ( uint16 Default = 0)
inline

Access the field as a uint16. Returns the provided default on error.

Definition at line 664 of file CompactBinary.h.

+ Here is the caller graph for this function:

◆ AsUInt32()

uint32 FCbFieldView::AsUInt32 ( uint32 Default = 0)
inline

Access the field as a uint32. Returns the provided default on error.

Definition at line 666 of file CompactBinary.h.

+ Here is the caller graph for this function:

◆ AsUInt64()

uint64 FCbFieldView::AsUInt64 ( uint64 Default = 0)
inline

Access the field as a uint64. Returns the provided default on error.

Definition at line 668 of file CompactBinary.h.

+ Here is the caller graph for this function:

◆ AsUInt8()

uint8 FCbFieldView::AsUInt8 ( uint8 Default = 0)
inline

Access the field as a uint8. Returns the provided default on error.

Definition at line 662 of file CompactBinary.h.

+ Here is the caller graph for this function:

◆ AsUuid() [1/2]

FGuid FCbFieldView::AsUuid ( )

Access the field as a UUID. Returns a nil UUID on error.

◆ AsUuid() [2/2]

FGuid FCbFieldView::AsUuid ( const FGuid & Default)

Access the field as a UUID. Returns the provided default on error.

◆ begin()

FCbFieldViewIterator FCbFieldView::begin ( ) const
inline

DO NOT USE DIRECTLY. These functions enable range-based for loop support.

Definition at line 922 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ CopyTo() [1/2]

void FCbFieldView::CopyTo ( FArchive & Ar) const

Copy the field into an archive, including its type and name.

◆ CopyTo() [2/2]

void FCbFieldView::CopyTo ( FMutableMemoryView Buffer) const

Copy the field into a buffer of exactly GetSize() bytes, including the type and name.

◆ CreateViewIterator()

FCbFieldViewIterator FCbFieldView::CreateViewIterator ( ) const

Create an iterator for the fields of an array or object, otherwise an empty iterator.

+ Here is the caller graph for this function:

◆ end()

constexpr FCbIteratorSentinel FCbFieldView::end ( ) const
inlineconstexpr

Definition at line 823 of file CompactBinary.h.

◆ Equals()

bool FCbFieldView::Equals ( const FCbFieldView & Other) const

Whether this field is identical to the other field.

Performs a deep comparison of any contained arrays or objects and their fields. Comparison assumes that both fields are valid and are written in the canonical format. Fields must be written in the same order in arrays and objects, and name comparison is case sensitive. If these assumptions do not hold, this may return false for equivalent inputs. Validation can be performed with ValidateCompactBinary, except for field order and field name case.

◆ GetError()

constexpr ECbFieldError FCbFieldView::GetError ( ) const
inlineconstexpr

The type of error that occurred on the last field access, or None.

Definition at line 769 of file CompactBinary.h.

◆ GetHash()

FIoHash FCbFieldView::GetHash ( ) const

Calculate the hash of the field, including the type and name.

◆ GetName()

constexpr FUtf8StringView FCbFieldView::GetName ( ) const
inlineconstexpr

Returns the name of the field if it has a name, otherwise an empty view.

Definition at line 633 of file CompactBinary.h.

◆ GetSize()

uint64 FCbFieldView::GetSize ( ) const

Returns the size of the field in bytes, including the type and name.

◆ GetType()

constexpr ECbFieldType FCbFieldView::GetType ( ) const
inlineconstexprprotected

Returns the type of the field excluding flags.

Definition at line 836 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ GetTypeWithFlags()

constexpr ECbFieldType FCbFieldView::GetTypeWithFlags ( ) const
inlineconstexprprotected

Returns the type of the field including flags.

Definition at line 839 of file CompactBinary.h.

◆ GetValue()

FORCEINLINE FCbValue FCbFieldView::GetValue ( ) const
inline

Returns the value for unchecked access. Prefer the typed accessors below.

Definition at line 78 of file CompactBinaryValue.h.

+ Here is the call graph for this function:

◆ GetValueData()

constexpr const void * FCbFieldView::GetValueData ( ) const
inlineconstexprprotected

Returns the start of the value.

Definition at line 842 of file CompactBinary.h.

◆ GetValueEnd()

const void * FCbFieldView::GetValueEnd ( ) const
inlineprotected

Returns the end of the value.

Definition at line 845 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ GetValueSize()

uint64 FCbFieldView::GetValueSize ( ) const
protected

Returns the size of the value in bytes, which is the field excluding the type and name.

+ Here is the caller graph for this function:

◆ GetValueView()

FMemoryView FCbFieldView::GetValueView ( ) const
inlineprotected

Returns a view of the value, which excludes the type and name.

Definition at line 833 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ GetView()

FMemoryView FCbFieldView::GetView ( ) const
protected

Returns a view of the field, including the type and name when present.

◆ GetViewNoType()

FMemoryView FCbFieldView::GetViewNoType ( ) const
protected

Returns a view of the name and value, which excludes the type.

◆ HasError()

constexpr bool FCbFieldView::HasError ( ) const
inlineconstexpr

Whether the last field access encountered an error.

Definition at line 766 of file CompactBinary.h.

+ Here is the caller graph for this function:

◆ HasName()

constexpr bool FCbFieldView::HasName ( ) const
inlineconstexpr

True if the field has a name.

Definition at line 723 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ HasValue()

constexpr bool FCbFieldView::HasValue ( ) const
inlineconstexpr

Whether the field has a value.

All fields in a valid object or array have a value. A field with no value is returned when finding a field by name fails or when accessing an iterator past the end.

Definition at line 763 of file CompactBinary.h.

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

◆ IsArray()

constexpr bool FCbFieldView::IsArray ( ) const
inlineconstexpr

Definition at line 728 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsAttachment()

constexpr bool FCbFieldView::IsAttachment ( ) const
inlineconstexpr

Definition at line 741 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsBinary()

constexpr bool FCbFieldView::IsBinary ( ) const
inlineconstexpr

Definition at line 730 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsBinaryAttachment()

constexpr bool FCbFieldView::IsBinaryAttachment ( ) const
inlineconstexpr

Definition at line 740 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsBool()

constexpr bool FCbFieldView::IsBool ( ) const
inlineconstexpr

Definition at line 737 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsCustomById()

constexpr bool FCbFieldView::IsCustomById ( ) const
inlineconstexpr

Definition at line 751 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsCustomByName()

constexpr bool FCbFieldView::IsCustomByName ( ) const
inlineconstexpr

Definition at line 752 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsDateTime()

constexpr bool FCbFieldView::IsDateTime ( ) const
inlineconstexpr

Definition at line 746 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsFloat()

constexpr bool FCbFieldView::IsFloat ( ) const
inlineconstexpr

Whether the field is a float, or integer that supports implicit conversion.

Definition at line 736 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsHash()

constexpr bool FCbFieldView::IsHash ( ) const
inlineconstexpr

Definition at line 743 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsInteger()

constexpr bool FCbFieldView::IsInteger ( ) const
inlineconstexpr

Whether the field is an integer of unspecified range and sign.

Definition at line 734 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsNull()

constexpr bool FCbFieldView::IsNull ( ) const
inlineconstexpr

Definition at line 725 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsObject()

constexpr bool FCbFieldView::IsObject ( ) const
inlineconstexpr

Definition at line 727 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsObjectAttachment()

constexpr bool FCbFieldView::IsObjectAttachment ( ) const
inlineconstexpr

Definition at line 739 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsObjectId()

constexpr bool FCbFieldView::IsObjectId ( ) const
inlineconstexpr

Definition at line 749 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsString()

constexpr bool FCbFieldView::IsString ( ) const
inlineconstexpr

Definition at line 731 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsTimeSpan()

constexpr bool FCbFieldView::IsTimeSpan ( ) const
inlineconstexpr

Definition at line 747 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IsUuid()

constexpr bool FCbFieldView::IsUuid ( ) const
inlineconstexpr

Definition at line 744 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ IterateAttachments()

void FCbFieldView::IterateAttachments ( FCbFieldVisitor Visitor) const

Invoke the visitor for every attachment in the field.

◆ operator bool()

constexpr FCbFieldView::operator bool ( ) const
inlineexplicitconstexpr

Whether the field has a value.

Definition at line 755 of file CompactBinary.h.

+ Here is the call graph for this function:

◆ operator[]()

FCbFieldView FCbFieldView::operator[] ( FUtf8StringView Name) const

Find a field of an object by case-sensitive name comparison, otherwise a field with no value.

◆ RemoveName()

constexpr FCbFieldView FCbFieldView::RemoveName ( ) const
inlineconstexpr

Returns a copy of the field with the name removed.

Definition at line 624 of file CompactBinary.h.

+ Here is the caller graph for this function:

◆ TryGetView()

bool FCbFieldView::TryGetView ( FMemoryView & OutView) const
inline

Try to get a view of the field as it would be serialized, such as by CopyTo.

A view is available if the field contains its type. Access the equivalent for other fields through FCbField::GetBuffer, FCbField::Clone, or CopyTo.

Definition at line 805 of file CompactBinary.h.

+ Here is the call graph for this function:

Member Data Documentation

◆ Error

ECbFieldError FCbFieldView::Error = ECbFieldError::None
private

The error (if any) that occurred on the last field access.

Definition at line 876 of file CompactBinary.h.

◆ NameLen

uint32 FCbFieldView::NameLen = 0
private

The number of bytes for the name stored before the value.

Definition at line 878 of file CompactBinary.h.

◆ TypeWithFlags

ECbFieldType FCbFieldView::TypeWithFlags = ECbFieldType::None
private

The field type, with the transient HasFieldType flag if the field contains its type.

Definition at line 874 of file CompactBinary.h.

◆ Value

const void* FCbFieldView::Value = nullptr
private

The value, which also points to the end of the name.

Definition at line 880 of file CompactBinary.h.


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