FCbFieldView

An atom of data in the compact binary format.

Choose your operating system:

Windows

macOS

Linux

Inheritance Hierarchy

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Serialization/CompactBinary.h

Include

#include "Serialization/CompactBinary.h"

Syntax

class FCbFieldView

Remarks

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.

Constructors

Name Description

Public function

FCbFieldView()

Construct a field with no name and no value.

Public function

FCbFieldView

(
    const FCbValue& Value
)

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

Public function

FCbFieldView

(
    const void* Data,
    ECbFieldType Type
)

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

Functions

Name Description

Public function Const

void

 

AppendHash

(
    FIoHashBuilder& Builder
)

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

Public function

FCbArrayView

 

AsArrayView()

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

Public function

FIoHash

 

AsAttachment

(
    const FIoHash& Default
)

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

Public function

FIoHash

 

AsBinaryAttachment

(
    const FIoHash& Default
)

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

Public function

FMemoryView

 

AsBinaryView

(
    FMemoryView Default
)

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

Public function

bool

 

AsBool

(
    bool bDefault
)

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

Public function

FMemoryView

 

AsCustom

(
    FUtf8StringView Name,
    FMemoryView Default
)

Access the field as a custom sub-type with a string identifier.

Public function

FMemoryView

 

AsCustom

(
    uint64 Id,
    FMemoryView Default
)

Access the field as a custom sub-type with an integer identifier.

Public function

FCbCustomByI...

 

AsCustomById

(
    FCbCustomById Default
)

Access the field as a custom sub-type with an integer identifier.

Public function

FCbCustomByN...

 

AsCustomByName

(
    FCbCustomByName Default
)

Access the field as a custom sub-type with a string identifier.

Public function

FDateTime

 

AsDateTime()

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

Public function

FDateTime

 

AsDateTime

(
    FDateTime Default
)

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

Public function

int64

 

AsDateTimeTicks

(
    int64 Default
)

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

Public function

double

 

AsDouble

(
    double Default
)

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

Public function

float

 

AsFloat

(
    float Default
)

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

Public function

FIoHash

 

AsHash

(
    const FIoHash& Default
)

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

Public function

int16

 

AsInt16

(
    int16 Default
)

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

Public function

int32

 

AsInt32

(
    int32 Default
)

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

Public function

int64

 

AsInt64

(
    int64 Default
)

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

Public function

int8

 

AsInt8

(
    int8 Default
)

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

Public function

FIoHash

 

AsObjectAttachment

(
    const FIoHash& Default
)

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

Public function

FCbObjectId

 

AsObjectId

(
    const FCbObjectId& Default
)

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

Public function

FCbObjectVie...

 

AsObjectView()

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

Protected function

void

 

Assign

(
    const void* InData,
    const ECbFieldType InType
)

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

Public function

FUtf8StringV...

 

AsString

(
    FUtf8StringView Default
)

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

Public function

FTimespan

 

AsTimeSpan

(
    FTimespan Default
)

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

Public function

FTimespan

 

AsTimeSpan()

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

Public function

int64

 

AsTimeSpanTicks

(
    int64 Default
)

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

Public function

uint16

 

AsUInt16

(
    uint16 Default
)

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

Public function

uint32

 

AsUInt32

(
    uint32 Default
)

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

Public function

uint64

 

AsUInt64

(
    uint64 Default
)

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

Public function

uint8

 

AsUInt8

(
    uint8 Default
)

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

Public function

FGuid

 

AsUuid

(
    const FGuid& Default
)

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

Public function

FGuid

 

AsUuid()

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

Public function Const

FCbFieldView...

 

begin()

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

Public function Const

void

 

CopyTo

(
    FArchive& Ar
)

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

Public function Const

void

 

CopyTo

(
    FMutableMemoryView Buffer
)

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

Public function Const

FCbFieldView...

 

CreateViewIterator()

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

Public function Const

constexpr FC...

 

end()

Public function Const

bool

 

Equals

(
    const FCbFieldView& Other
)

Whether this field is identical to the other field.

Public function Const

constexpr EC...

 

GetError()

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

Public function Const

FIoHash

 

GetHash()

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

Public function Const

constexpr FU...

 

GetName()

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

Public function Const

uint64

 

GetSize()

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

Protected function Const

constexpr EC...

 

GetType()

Returns the type of the field excluding flags.

Protected function Const

constexpr EC...

 

GetTypeWithFlags()

Returns the type of the field including flags.

Public function Const

FCbValue

 

GetValue()

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

Protected function Const

constexpr co...

 

GetValueData()

Returns the start of the value.

Protected function Const

const void &...

 

GetValueEnd()

Returns the end of the value.

Protected function Const

uint64

 

GetValueSize()

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

Protected function Const

FMemoryView

 

GetValueView()

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

Protected function Const

FMemoryView

 

GetView()

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

Protected function Const

FMemoryView

 

GetViewNoType()

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

Public function Const

constexpr bo...

 

HasError()

Whether the last field access encountered an error.

Public function Const

constexpr bo...

 

HasName()

True if the field has a name.

Public function Const

constexpr bo...

 

HasValue()

Whether the field has a value.

Public function Const

constexpr bo...

 

IsArray()

Public function Const

constexpr bo...

 

IsAttachment()

Public function Const

constexpr bo...

 

IsBinary()

Public function Const

constexpr bo...

 

IsBinaryAttachment()

Public function Const

constexpr bo...

 

IsBool()

Public function Const

constexpr bo...

 

IsCustomById()

Public function Const

constexpr bo...

 

IsCustomByName()

Public function Const

constexpr bo...

 

IsDateTime()

Public function Const

constexpr bo...

 

IsFloat()

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

Public function Const

constexpr bo...

 

IsHash()

Public function Const

constexpr bo...

 

IsInteger()

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

Public function Const

constexpr bo...

 

IsNull()

Public function Const

constexpr bo...

 

IsObject()

Public function Const

constexpr bo...

 

IsObjectAttachment()

Public function Const

constexpr bo...

 

IsObjectId()

Public function Const

constexpr bo...

 

IsString()

Public function Const

constexpr bo...

 

IsTimeSpan()

Public function Const

constexpr bo...

 

IsUuid()

Public function Const

void

 

IterateAttachments

(
    FCbFieldVisitor Visitor
)

Invoke the visitor for every attachment in the field.

Public function Const

bool

 

TryGetView

(
    FMemoryView& OutView
)

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

Operators

Name Description

Public function Const

constexpr

 

operator bool()

Whether the field has a value.

Public function Const

FCbFieldView

 

operator[]

(
    FUtf8StringView Name
)

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