Ark Server API (ASA) - Wiki
|
#include <CompactBinary.h>
Protected Member Functions | |
FMemoryView | GetView () const |
FMemoryView | GetViewNoType () const |
FMemoryView | GetValueView () const |
constexpr ECbFieldType | GetType () const |
constexpr ECbFieldType | GetTypeWithFlags () const |
constexpr const void * | GetValueData () const |
const void * | GetValueEnd () 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 void * | Value = nullptr |
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.
|
constexprdefault |
Construct a field with no name and no value.
|
explicit |
Construct a field from a pointer to its data and an optional externally-provided type.
Data | Pointer to the start of the field data. |
Type | HasFieldType means that Data contains the type. Otherwise, use the given type. |
|
inlineexplicit |
Construct a field from a value, without access to the name.
Definition at line 72 of file CompactBinaryValue.h.
void FCbFieldView::AppendHash | ( | FIoHashBuilder & | Builder | ) | const |
Append the hash of the field, including the type and name.
FCbArrayView FCbFieldView::AsArrayView | ( | ) |
Access the field as an array. Defaults to an empty array on error.
Access the field as a hash referencing an attachment. Returns the provided default on error.
Access the field as a hash referencing a binary attachment. Returns the provided default on error.
FMemoryView FCbFieldView::AsBinaryView | ( | FMemoryView | Default = FMemoryView() | ) |
Access the field as binary. Returns the provided default on error.
Access the field as a bool. Returns the provided default on error.
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.
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.
FCbCustomById FCbFieldView::AsCustomById | ( | FCbCustomById | Default = FCbCustomById() | ) |
Access the field as a custom sub-type with an integer identifier. Returns the provided default on error.
FCbCustomByName FCbFieldView::AsCustomByName | ( | FCbCustomByName | Default = FCbCustomByName() | ) |
Access the field as a custom sub-type with a string identifier. Returns the provided default on error.
FDateTime FCbFieldView::AsDateTime | ( | ) |
Access the field as a date/time. Returns a date/time at the epoch on error.
Access the field as a date/time. Returns the provided default on error.
Access the field as a date/time tick count. Returns the provided default on error.
Access the field as a double. Returns the provided default on error.
Access the field as a float. Returns the provided default on error.
Access the field as a hash. Returns the provided default on error.
Access the field as an int16. Returns the provided default on error.
Definition at line 656 of file CompactBinary.h.
Access the field as an int32. Returns the provided default on error.
Definition at line 658 of file CompactBinary.h.
Access the field as an int64. Returns the provided default on error.
Definition at line 660 of file CompactBinary.h.
Access the field as an int8. Returns the provided default on error.
Definition at line 654 of file CompactBinary.h.
|
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.
|
private |
Access the field as a hash referencing an object attachment. Returns the provided default on error.
FCbObjectId FCbFieldView::AsObjectId | ( | const FCbObjectId & | Default = FCbObjectId() | ) |
Access the field as an object identifier. Returns the provided default on error.
FCbObjectView FCbFieldView::AsObjectView | ( | ) |
Access the field as an object. Defaults to an empty object on error.
|
inlineprotected |
Assign a field from a pointer to its data and an optional externally-provided type.
Definition at line 851 of file CompactBinary.h.
FUtf8StringView FCbFieldView::AsString | ( | FUtf8StringView | Default = FUtf8StringView() | ) |
Access the field as a string. Returns the provided default on error.
FTimespan FCbFieldView::AsTimeSpan | ( | ) |
Access the field as a timespan. Returns an empty timespan on error.
Access the field as a timespan. Returns the provided default on error.
Access the field as a timespan tick count. Returns the provided default on error.
Access the field as a uint16. Returns the provided default on error.
Definition at line 664 of file CompactBinary.h.
Access the field as a uint32. Returns the provided default on error.
Definition at line 666 of file CompactBinary.h.
Access the field as a uint64. Returns the provided default on error.
Definition at line 668 of file CompactBinary.h.
Access the field as a uint8. Returns the provided default on error.
Definition at line 662 of file CompactBinary.h.
FGuid FCbFieldView::AsUuid | ( | ) |
Access the field as a UUID. Returns a nil UUID on error.
Access the field as a UUID. Returns the provided default on error.
|
inline |
DO NOT USE DIRECTLY. These functions enable range-based for loop support.
Definition at line 922 of file CompactBinary.h.
Copy the field into an archive, including its type and name.
void FCbFieldView::CopyTo | ( | FMutableMemoryView | Buffer | ) | const |
Copy the field into a buffer of exactly GetSize() bytes, including the type and name.
FCbFieldViewIterator FCbFieldView::CreateViewIterator | ( | ) | const |
Create an iterator for the fields of an array or object, otherwise an empty iterator.
|
inlineconstexpr |
Definition at line 823 of file CompactBinary.h.
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.
|
inlineconstexpr |
The type of error that occurred on the last field access, or None.
Definition at line 769 of file CompactBinary.h.
FIoHash FCbFieldView::GetHash | ( | ) | const |
Calculate the hash of the field, including the type and name.
|
inlineconstexpr |
Returns the name of the field if it has a name, otherwise an empty view.
Definition at line 633 of file CompactBinary.h.
uint64 FCbFieldView::GetSize | ( | ) | const |
Returns the size of the field in bytes, including the type and name.
|
inlineconstexprprotected |
Returns the type of the field excluding flags.
Definition at line 836 of file CompactBinary.h.
|
inlineconstexprprotected |
Returns the type of the field including flags.
Definition at line 839 of file CompactBinary.h.
|
inline |
Returns the value for unchecked access. Prefer the typed accessors below.
Definition at line 78 of file CompactBinaryValue.h.
Returns the start of the value.
Definition at line 842 of file CompactBinary.h.
Returns the end of the value.
Definition at line 845 of file CompactBinary.h.
|
protected |
Returns the size of the value in bytes, which is the field excluding the type and name.
|
inlineprotected |
Returns a view of the value, which excludes the type and name.
Definition at line 833 of file CompactBinary.h.
|
protected |
Returns a view of the field, including the type and name when present.
|
protected |
Returns a view of the name and value, which excludes the type.
Whether the last field access encountered an error.
Definition at line 766 of file CompactBinary.h.
True if the field has a name.
Definition at line 723 of file CompactBinary.h.
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.
Whether the field is a float, or integer that supports implicit conversion.
Definition at line 736 of file CompactBinary.h.
Whether the field is an integer of unspecified range and sign.
Definition at line 734 of file CompactBinary.h.
void FCbFieldView::IterateAttachments | ( | FCbFieldVisitor | Visitor | ) | const |
Invoke the visitor for every attachment in the field.
Whether the field has a value.
Definition at line 755 of file CompactBinary.h.
FCbFieldView FCbFieldView::operator[] | ( | FUtf8StringView | Name | ) | const |
Find a field of an object by case-sensitive name comparison, otherwise a field with no value.
|
inlineconstexpr |
Returns a copy of the field with the name removed.
Definition at line 624 of file CompactBinary.h.
|
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.
|
private |
The error (if any) that occurred on the last field access.
Definition at line 876 of file CompactBinary.h.
|
private |
The number of bytes for the name stored before the value.
Definition at line 878 of file CompactBinary.h.
|
private |
The field type, with the transient HasFieldType flag if the field contains its type.
Definition at line 874 of file CompactBinary.h.
The value, which also points to the end of the name.
Definition at line 880 of file CompactBinary.h.