Ark Server API (ASA) - Wiki
|
#include <CompactBinaryPackage.h>
Public Types | |
using | FAttachmentResolver = TFunctionRef<FSharedBuffer (const FIoHash& Hash)> |
Private Member Functions | |
void | SetObject (FCbObject Object, const FIoHash *Hash, FAttachmentResolver *Resolver) |
void | AddAttachment (const FCbAttachment &Attachment, FAttachmentResolver *Resolver) |
void | GatherAttachments (const FCbObject &Object, FAttachmentResolver Resolver) |
Private Attributes | |
TArray< FCbAttachment > | Attachments |
FCbObject | Object |
FIoHash | ObjectHash |
A package is an object with a tree of referenced attachments.
A package is a Merkle tree with an object as its root and non-leaf nodes, and either binary or objects as its leaf nodes. Nodes reference their children from fields of type BinaryAttachment or ObjectAttachment, which store the raw hash of the referenced attachment.
It is invalid for a package to include attachments that are not referenced by its object or by one of its referenced object attachments. This invariant needs to be maintained if attachments are added explicitly instead of being discovered by the attachment resolver. If any attachment is not referenced, it may not survive a round-trip through certain storage systems.
It is valid for a package to exclude referenced attachments, but then it is the responsibility of the package consumer to have a mechanism for resolving those references when necessary.
A package is serialized as a sequence of compact binary fields with no name. The object may be both preceded and followed by attachments. The object is only serialized when it is non-empty, starting with its hash, in a Hash field, followed by the object, in an Object field. A package ends with a Null field. The canonical order of components is the object and its hash, followed by the attachments ordered by hash, followed by a Null field. It is valid for the a package to have its attachments serialized in any order relative to each other and to the object.
Definition at line 218 of file CompactBinaryPackage.h.
A function that resolves a hash to a buffer containing the data matching that hash.
The resolver may return a null buffer to skip resolving an attachment for the hash.
Definition at line 226 of file CompactBinaryPackage.h.
|
default |
Construct a null package.
|
inlineexplicit |
Construct a package from a root object without gathering attachments.
InObject | The root object, which will be cloned unless it is owned. |
Definition at line 236 of file CompactBinaryPackage.h.
|
inlineexplicit |
Construct a package from a root object and gather attachments using the resolver.
InObject | The root object, which will be cloned unless it is owned. |
InResolver | A function that is invoked for every reference and binary reference field. |
Definition at line 247 of file CompactBinaryPackage.h.
Construct a package from a root object without gathering attachments.
InObject | The root object, which will be cloned unless it is owned. |
InObjectHash | The hash of the object, which must match to avoid validation errors. |
Definition at line 258 of file CompactBinaryPackage.h.
|
inlineexplicit |
Construct a package from a root object and gather attachments using the resolver.
InObject | The root object, which will be cloned unless it is owned. |
InObjectHash | The hash of the object, which must match to avoid validation errors. |
InResolver | A function that is invoked for every reference and binary reference field. |
Definition at line 270 of file CompactBinaryPackage.h.
|
inline |
Add the attachment to this package.
Definition at line 352 of file CompactBinaryPackage.h.
|
private |
|
inline |
Add the attachment to this package, along with any references that can be resolved.
Definition at line 358 of file CompactBinaryPackage.h.
bool FCbPackage::Equals | ( | const FCbPackage & | Package | ) | const |
Compares packages by their object and attachment hashes.
|
inline |
Find an attachment if it exists in the package.
Definition at line 346 of file CompactBinaryPackage.h.
const FCbAttachment * FCbPackage::FindAttachment | ( | const FIoHash & | Hash | ) | const |
Find an attachment by its hash.
|
private |
|
inline |
Returns the attachments in this package.
Definition at line 335 of file CompactBinaryPackage.h.
Returns the object for the package.
Definition at line 285 of file CompactBinaryPackage.h.
Returns the hash of the object for the package.
Definition at line 288 of file CompactBinaryPackage.h.
|
inline |
Whether the package has an empty object and no attachments.
Definition at line 282 of file CompactBinaryPackage.h.
|
inlineexplicit |
Whether the package has a non-empty object or attachments.
Definition at line 279 of file CompactBinaryPackage.h.
|
inline |
|
inline |
|
inline |
Definition at line 369 of file CompactBinaryPackage.h.
Remove an attachment by hash.
|
inline |
Reset this to a null package.
Definition at line 276 of file CompactBinaryPackage.h.
Save the object and attachments into the archive as a stream of compact binary fields.
Save the object and attachments into the writer as a stream of compact binary fields.
Set the root object without gathering attachments.
InObject | The root object, which will be cloned unless it is owned. |
Definition at line 295 of file CompactBinaryPackage.h.
Set the root object without gathering attachments.
InObject | The root object, which will be cloned unless it is owned. |
InObjectHash | The hash of the object, which must match to avoid validation errors. |
Definition at line 317 of file CompactBinaryPackage.h.
|
inline |
Set the root object and gather attachments using the resolver.
InObject | The root object, which will be cloned unless it is owned. |
InObjectHash | The hash of the object, which must match to avoid validation errors. |
InResolver | A function that is invoked for every reference and binary reference field. |
Definition at line 329 of file CompactBinaryPackage.h.
|
inline |
Set the root object and gather attachments using the resolver.
InObject | The root object, which will be cloned unless it is owned. |
InResolver | A function that is invoked for every reference and binary reference field. |
Definition at line 306 of file CompactBinaryPackage.h.
|
private |
bool FCbPackage::TryLoad | ( | FArchive & | Ar, |
FCbBufferAllocator | Allocator = FUniqueBuffer::Alloc ) |
Load the object and attachments from compact binary as written by Save.
The object and attachments will be individually loaded into owned buffers.
Ar | Archive to read the package from. An error state is set on failure. |
Allocator | Allocator for object and attachment buffers. |
bool FCbPackage::TryLoad | ( | FCbFieldIterator & | Fields | ) |
Load the object and attachments from compact binary as written by Save.
The object and attachments reference the input iterator, if it is owned, and otherwise clones the object and attachments individually to make owned copies.
The iterator is advanced as object and attachment fields are consumed from it.
|
private |
Attachments ordered by their hash.
Definition at line 410 of file CompactBinaryPackage.h.
|
private |
Definition at line 411 of file CompactBinaryPackage.h.
|
private |
Definition at line 412 of file CompactBinaryPackage.h.