UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FCbFieldView Class Reference

#include <CompactBinary.h>

+ Inheritance diagram for FCbFieldView:

Public Member Functions

constexpr FCbFieldView ()=default
 
CORE_API FCbFieldView (const void *Data, ECbFieldType Type=ECbFieldType::HasFieldType)
 
 FCbFieldView (const FCbValue &Value)
 
constexpr FCbFieldView RemoveName () const
 
constexpr FUtf8StringView GetName () const
 
FCbValue GetValue () const
 
CORE_API FCbObjectView AsObjectView ()
 
CORE_API FCbArrayView AsArrayView ()
 
CORE_API FMemoryView AsBinaryView (FMemoryView Default=FMemoryView())
 
CORE_API 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)
 
CORE_API float AsFloat (float Default=0.0f)
 
CORE_API double AsDouble (double Default=0.0)
 
CORE_API bool AsBool (bool bDefault=false)
 
CORE_API FIoHash AsObjectAttachment (const FIoHash &Default=FIoHash())
 
CORE_API FIoHash AsBinaryAttachment (const FIoHash &Default=FIoHash())
 
CORE_API FIoHash AsAttachment (const FIoHash &Default=FIoHash())
 
CORE_API FIoHash AsHash (const FIoHash &Default=FIoHash())
 
CORE_API FGuid AsUuid ()
 
CORE_API FGuid AsUuid (const FGuid &Default)
 
CORE_API int64 AsDateTimeTicks (int64 Default=0)
 
CORE_API FDateTime AsDateTime ()
 
CORE_API FDateTime AsDateTime (FDateTime Default)
 
CORE_API int64 AsTimeSpanTicks (int64 Default=0)
 
CORE_API FTimespan AsTimeSpan ()
 
CORE_API FTimespan AsTimeSpan (FTimespan Default)
 
CORE_API FCbObjectId AsObjectId (const FCbObjectId &Default=FCbObjectId())
 
CORE_API FCbCustomById AsCustomById (FCbCustomById Default=FCbCustomById())
 
CORE_API FCbCustomByName AsCustomByName (FCbCustomByName Default=FCbCustomByName())
 
CORE_API FMemoryView AsCustom (uint64 Id, FMemoryView Default=FMemoryView())
 
CORE_API 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
 
CORE_API uint64 GetSize () const
 
CORE_API FIoHash GetHash () const
 
CORE_API void AppendHash (FIoHashBuilder &Builder) const
 
CORE_API bool Equals (const FCbFieldView &Other) const
 
CORE_API void CopyTo (FMutableMemoryView Buffer) const
 
CORE_API void CopyTo (FArchive &Ar) const
 
CORE_API void IterateAttachments (FCbFieldVisitor Visitor) const
 
bool TryGetView (FMemoryView &OutView) const
 
CORE_API FCbFieldView operator[] (FUtf8StringView Name) const
 
CORE_API FCbFieldViewIterator CreateViewIterator () const
 
FCbFieldViewIterator begin () const
 
constexpr FCbIteratorSentinel end () const
 

Protected Member Functions

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

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.

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.

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.

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

◆ AsFloat()

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

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

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

◆ AsInt32()

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

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

◆ AsInt64()

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

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

◆ AsInt8()

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

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

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

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

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

◆ AsUInt32()

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

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

◆ AsUInt64()

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

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

◆ AsUInt8()

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

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

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

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

◆ end()

constexpr FCbIteratorSentinel FCbFieldView::end ( ) const
inlineconstexpr

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

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

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

◆ GetTypeWithFlags()

constexpr ECbFieldType FCbFieldView::GetTypeWithFlags ( ) const
inlineconstexprprotected

Returns the type of the field including flags.

◆ GetValue()

FORCEINLINE FCbValue FCbFieldView::GetValue ( ) const
inline

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

◆ GetValueData()

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

Returns the start of the value.

◆ GetValueEnd()

const void * FCbFieldView::GetValueEnd ( ) const
inlineprotected

Returns the end of the value.

◆ GetValueSize()

uint64 FCbFieldView::GetValueSize ( ) const
protected

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

◆ GetValueView()

FMemoryView FCbFieldView::GetValueView ( ) const
inlineprotected

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

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

◆ HasName()

constexpr bool FCbFieldView::HasName ( ) const
inlineconstexpr

True if the field has a name.

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

◆ IsArray()

constexpr bool FCbFieldView::IsArray ( ) const
inlineconstexpr

◆ IsAttachment()

constexpr bool FCbFieldView::IsAttachment ( ) const
inlineconstexpr

◆ IsBinary()

constexpr bool FCbFieldView::IsBinary ( ) const
inlineconstexpr

◆ IsBinaryAttachment()

constexpr bool FCbFieldView::IsBinaryAttachment ( ) const
inlineconstexpr

◆ IsBool()

constexpr bool FCbFieldView::IsBool ( ) const
inlineconstexpr

◆ IsCustomById()

constexpr bool FCbFieldView::IsCustomById ( ) const
inlineconstexpr

◆ IsCustomByName()

constexpr bool FCbFieldView::IsCustomByName ( ) const
inlineconstexpr

◆ IsDateTime()

constexpr bool FCbFieldView::IsDateTime ( ) const
inlineconstexpr

◆ IsFloat()

constexpr bool FCbFieldView::IsFloat ( ) const
inlineconstexpr

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

◆ IsHash()

constexpr bool FCbFieldView::IsHash ( ) const
inlineconstexpr

◆ IsInteger()

constexpr bool FCbFieldView::IsInteger ( ) const
inlineconstexpr

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

◆ IsNull()

constexpr bool FCbFieldView::IsNull ( ) const
inlineconstexpr

◆ IsObject()

constexpr bool FCbFieldView::IsObject ( ) const
inlineconstexpr

◆ IsObjectAttachment()

constexpr bool FCbFieldView::IsObjectAttachment ( ) const
inlineconstexpr

◆ IsObjectId()

constexpr bool FCbFieldView::IsObjectId ( ) const
inlineconstexpr

◆ IsString()

constexpr bool FCbFieldView::IsString ( ) const
inlineconstexpr

◆ IsTimeSpan()

constexpr bool FCbFieldView::IsTimeSpan ( ) const
inlineconstexpr

◆ IsUuid()

constexpr bool FCbFieldView::IsUuid ( ) const
inlineconstexpr

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

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

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


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