![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <CompactBinaryPackage.h>
Public Types | |
| using | FAttachmentResolver = TFunctionRef< FSharedBuffer(const FIoHash &Hash)> |
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.
| using FCbPackage::FAttachmentResolver = TFunctionRef<FSharedBuffer (const FIoHash& Hash)> |
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.
|
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. |
|
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. |
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. |
|
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. |
|
inline |
Add the attachment to this package.
|
inline |
Add the attachment to this package, along with any references that can be resolved.
| 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.
| const FCbAttachment * FCbPackage::FindAttachment | ( | const FIoHash & | Hash | ) | const |
Find an attachment by its hash.
|
inline |
Returns the attachments in this package.
|
inline |
Returns the object for the package.
|
inline |
Returns the hash of the object for the package.
|
inline |
Whether the package has an empty object and no attachments.
|
inlineexplicit |
Whether the package has a non-empty object or attachments.
|
inline |
|
inline |
|
inline |
Remove an attachment by hash.
|
inline |
Reset this to a null package.
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. |
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. |
|
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. |
|
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. |
| 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.