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