Navigation
API > API/Runtime > API/Runtime/Core
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.
| Name | FCbFieldView |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Serialization/CompactBinary.h |
| Include Path | #include "Serialization/CompactBinary.h" |
Syntax
class FCbFieldView
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
constexpr FCbFieldView () |
Construct a field with no name and no value. | Serialization/CompactBinary.h | |
FCbFieldView
(
const void* Data, |
Construct a field from a pointer to its data and an optional externally-provided type. | Serialization/CompactBinary.h | |
FCbFieldView
(
const FCbValue& Value |
Construct a field from a value, without access to the name. | Serialization/CompactBinary.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Error | ECbFieldError | The error (if any) that occurred on the last field access. | Serialization/CompactBinary.h | |
| NameLen | uint32 | The number of bytes for the name stored before the value. | Serialization/CompactBinary.h | |
| TypeWithFlags | ECbFieldType | The field type, with the transient HasFieldType flag if the field contains its type. | Serialization/CompactBinary.h | |
| Value | const void * | The value, which also points to the end of the name. | Serialization/CompactBinary.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AppendHash
(
FIoHashBuilder& Builder |
Append the hash of the field, including the type and name. | Serialization/CompactBinary.h | |
FCbArrayView AsArrayView() |
Access the field as an array. Defaults to an empty array on error. | Serialization/CompactBinary.h | |
| Access the field as a hash referencing an attachment. Returns the provided default on error. | Serialization/CompactBinary.h | ||
| Access the field as a hash referencing a binary attachment. Returns the provided default on error. | Serialization/CompactBinary.h | ||
FMemoryView AsBinaryView
(
FMemoryView Default |
Access the field as binary. Returns the provided default on error. | Serialization/CompactBinary.h | |
bool AsBool
(
bool bDefault |
Access the field as a bool. Returns the provided default on error. | Serialization/CompactBinary.h | |
FMemoryView AsCustom
(
FUtf8StringView Name, |
Access the field as a custom sub-type with a string identifier. | Serialization/CompactBinary.h | |
FMemoryView AsCustom
(
uint64 Id, |
Access the field as a custom sub-type with an integer identifier. | Serialization/CompactBinary.h | |
FCbCustomById AsCustomById
(
FCbCustomById Default |
Access the field as a custom sub-type with an integer identifier. | Serialization/CompactBinary.h | |
FCbCustomByName AsCustomByName
(
FCbCustomByName Default |
Access the field as a custom sub-type with a string identifier. | Serialization/CompactBinary.h | |
| Access the field as a date/time. Returns a date/time at the epoch on error. | Serialization/CompactBinary.h | ||
FDateTime AsDateTime
(
FDateTime Default |
Access the field as a date/time. Returns the provided default on error. | Serialization/CompactBinary.h | |
int64 AsDateTimeTicks
(
int64 Default |
Access the field as a date/time tick count. Returns the provided default on error. | Serialization/CompactBinary.h | |
double AsDouble
(
double Default |
Access the field as a double. Returns the provided default on error. | Serialization/CompactBinary.h | |
float AsFloat
(
float Default |
Access the field as a float. Returns the provided default on error. | Serialization/CompactBinary.h | |
| Access the field as a hash. Returns the provided default on error. | Serialization/CompactBinary.h | ||
int16 AsInt16
(
int16 Default |
Access the field as an int16. Returns the provided default on error. | Serialization/CompactBinary.h | |
int32 AsInt32
(
int32 Default |
Access the field as an int32. Returns the provided default on error. | Serialization/CompactBinary.h | |
int64 AsInt64
(
int64 Default |
Access the field as an int64. Returns the provided default on error. | Serialization/CompactBinary.h | |
int8 AsInt8
(
int8 Default |
Access the field as an int8. Returns the provided default on error. | Serialization/CompactBinary.h | |
| Access the field as a hash referencing an object attachment. Returns the provided default on error. | Serialization/CompactBinary.h | ||
FCbObjectId AsObjectId
(
const FCbObjectId& Default |
Access the field as an object identifier. Returns the provided default on error. | Serialization/CompactBinary.h | |
FCbObjectView AsObjectView() |
Access the field as an object. Defaults to an empty object on error. | Serialization/CompactBinary.h | |
FUtf8StringView AsString
(
FUtf8StringView Default |
Access the field as a string. Returns the provided default on error. | Serialization/CompactBinary.h | |
| Access the field as a timespan. Returns an empty timespan on error. | Serialization/CompactBinary.h | ||
FTimespan AsTimeSpan
(
FTimespan Default |
Access the field as a timespan. Returns the provided default on error. | Serialization/CompactBinary.h | |
int64 AsTimeSpanTicks
(
int64 Default |
Access the field as a timespan tick count. Returns the provided default on error. | Serialization/CompactBinary.h | |
uint16 AsUInt16
(
uint16 Default |
Access the field as a uint16. Returns the provided default on error. | Serialization/CompactBinary.h | |
uint32 AsUInt32
(
uint32 Default |
Access the field as a uint32. Returns the provided default on error. | Serialization/CompactBinary.h | |
uint64 AsUInt64
(
uint64 Default |
Access the field as a uint64. Returns the provided default on error. | Serialization/CompactBinary.h | |
uint8 AsUInt8
(
uint8 Default |
Access the field as a uint8. Returns the provided default on error. | Serialization/CompactBinary.h | |
| Access the field as a UUID. Returns the provided default on error. | Serialization/CompactBinary.h | ||
| Access the field as a UUID. Returns a nil UUID on error. | Serialization/CompactBinary.h | ||
FCbFieldViewIterator begin() |
DO NOT USE DIRECTLY. These functions enable range-based for loop support. | Serialization/CompactBinary.h | |
| Copy the field into an archive, including its type and name. | Serialization/CompactBinary.h | ||
void CopyTo
(
FMutableMemoryView Buffer |
Copy the field into a buffer of exactly GetSize() bytes, including the type and name. | Serialization/CompactBinary.h | |
FCbFieldViewIterator CreateViewIterator() |
Create an iterator for the fields of an array or object, otherwise an empty iterator. | Serialization/CompactBinary.h | |
FCbIteratorSentinel end() |
Serialization/CompactBinary.h | ||
bool Equals
(
const FCbFieldView& Other |
Whether this field is identical to the other field. | Serialization/CompactBinary.h | |
ECbFieldError GetError() |
The type of error that occurred on the last field access, or None. | Serialization/CompactBinary.h | |
FIoHash GetHash() |
Calculate the hash of the field, including the type and name. | Serialization/CompactBinary.h | |
FUtf8StringView GetName() |
Returns the name of the field if it has a name, otherwise an empty view. | Serialization/CompactBinary.h | |
uint64 GetSize() |
Returns the size of the field in bytes, including the type and name. | Serialization/CompactBinary.h | |
FCbValue GetValue() |
Returns the value for unchecked access. Prefer the typed accessors below. | Serialization/CompactBinary.h | |
bool HasError() |
Whether the last field access encountered an error. | Serialization/CompactBinary.h | |
bool HasName() |
True if the field has a name. | Serialization/CompactBinary.h | |
bool HasValue () |
Whether the field has a value. | Serialization/CompactBinary.h | |
bool IsArray() |
Serialization/CompactBinary.h | ||
bool IsAttachment() |
Serialization/CompactBinary.h | ||
bool IsBinary() |
Serialization/CompactBinary.h | ||
bool IsBinaryAttachment() |
Serialization/CompactBinary.h | ||
bool IsBool() |
Serialization/CompactBinary.h | ||
bool IsCustomById() |
Serialization/CompactBinary.h | ||
bool IsCustomByName() |
Serialization/CompactBinary.h | ||
bool IsDateTime() |
Serialization/CompactBinary.h | ||
bool IsFloat() |
Whether the field is a float, or integer that supports implicit conversion. | Serialization/CompactBinary.h | |
bool IsHash() |
Serialization/CompactBinary.h | ||
bool IsInteger() |
Whether the field is an integer of unspecified range and sign. | Serialization/CompactBinary.h | |
bool IsNull() |
Serialization/CompactBinary.h | ||
bool IsObject() |
Serialization/CompactBinary.h | ||
bool IsObjectAttachment() |
Serialization/CompactBinary.h | ||
bool IsObjectId() |
Serialization/CompactBinary.h | ||
bool IsString() |
Serialization/CompactBinary.h | ||
bool IsTimeSpan() |
Serialization/CompactBinary.h | ||
bool IsUuid() |
Serialization/CompactBinary.h | ||
void IterateAttachments
(
FCbFieldVisitor Visitor |
Invoke the visitor for every attachment in the field. | Serialization/CompactBinary.h | |
FCbFieldView RemoveName() |
Returns a copy of the field with the name removed. | Serialization/CompactBinary.h | |
bool TryGetView
(
FMemoryView& OutView |
Try to get a view of the field as it would be serialized, such as by CopyTo. | Serialization/CompactBinary.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Assign
(
const void* InData, |
Assign a field from a pointer to its data and an optional externally-provided type. | Serialization/CompactBinary.h | |
ECbFieldType GetType() |
Returns the type of the field excluding flags. | Serialization/CompactBinary.h | |
ECbFieldType GetTypeWithFlags() |
Returns the type of the field including flags. | Serialization/CompactBinary.h | |
const void * GetValueData() |
Returns the start of the value. | Serialization/CompactBinary.h | |
const void * GetValueEnd() |
Returns the end of the value. | Serialization/CompactBinary.h | |
uint64 GetValueSize() |
Returns the size of the value in bytes, which is the field excluding the type and name. | Serialization/CompactBinary.h | |
FMemoryView GetValueView() |
Returns a view of the value, which excludes the type and name. | Serialization/CompactBinary.h | |
FMemoryView GetView() |
Returns a view of the field, including the type and name when present. | Serialization/CompactBinary.h | |
FMemoryView GetViewNoType() |
Returns a view of the name and value, which excludes the type. | Serialization/CompactBinary.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
constexpr operator bool() |
Whether the field has a value. | Serialization/CompactBinary.h | |
FCbFieldView operator[]
(
FUtf8StringView Name |
Find a field of an object by case-sensitive name comparison, otherwise a field with no value. | Serialization/CompactBinary.h |