Navigation
API > API/Runtime > API/Runtime/Core
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.
| Name | FCbPackage |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Serialization/CompactBinaryPackage.h |
| Include Path | #include "Serialization/CompactBinaryPackage.h" |
Syntax
class FCbPackage
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FCbPackage
(
FCbObject InObject, |
Construct a package from a root object and gather attachments using the resolver. | Serialization/CompactBinaryPackage.h | |
FCbPackage
(
FCbObject InObject, |
Construct a package from a root object without gathering attachments. | Serialization/CompactBinaryPackage.h | |
FCbPackage
(
FCbObject InObject |
Construct a package from a root object without gathering attachments. | Serialization/CompactBinaryPackage.h | |
FCbPackage () |
Construct a null package. | Serialization/CompactBinaryPackage.h | |
FCbPackage
(
FCbObject InObject, |
Construct a package from a root object and gather attachments using the resolver. | Serialization/CompactBinaryPackage.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FAttachmentResolver | TFunctionRef< FSharedBuffer(const FIoHash &Hash)> | A function that resolves a hash to a buffer containing the data matching that hash. | Serialization/CompactBinaryPackage.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Attachments | TArray< FCbAttachment > | Attachments ordered by their hash. | Serialization/CompactBinaryPackage.h | |
| Object | FCbObject | Serialization/CompactBinaryPackage.h | ||
| ObjectHash | FIoHash | Serialization/CompactBinaryPackage.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddAttachment
(
const FCbAttachment& Attachment, |
Add the attachment to this package, along with any references that can be resolved. | Serialization/CompactBinaryPackage.h | |
void AddAttachment
(
const FCbAttachment& Attachment |
Add the attachment to this package. | Serialization/CompactBinaryPackage.h | |
bool Equals
(
const FCbPackage& Package |
Compares packages by their object and attachment hashes. | Serialization/CompactBinaryPackage.h | |
const FCbAttachment * FindAttachment
(
const FCbAttachment& Attachment |
Find an attachment if it exists in the package. | Serialization/CompactBinaryPackage.h | |
const FCbAttachment * FindAttachment
(
const FIoHash& Hash |
Find an attachment by its hash. | Serialization/CompactBinaryPackage.h | |
TConstArrayView< FCbAttachment > GetAttachments() |
Returns the attachments in this package. | Serialization/CompactBinaryPackage.h | |
const FCbObject & GetObject() |
Returns the object for the package. | Serialization/CompactBinaryPackage.h | |
const FIoHash & GetObjectHash() |
Returns the hash of the object for the package. | Serialization/CompactBinaryPackage.h | |
bool IsNull() |
Whether the package has an empty object and no attachments. | Serialization/CompactBinaryPackage.h | |
int32 RemoveAttachment
(
const FCbAttachment& Attachment |
Serialization/CompactBinaryPackage.h | ||
int32 RemoveAttachment
(
const FIoHash& Hash |
Remove an attachment by hash. | Serialization/CompactBinaryPackage.h | |
void Reset() |
Reset this to a null package. | Serialization/CompactBinaryPackage.h | |
| Save the object and attachments into the writer as a stream of compact binary fields. | Serialization/CompactBinaryPackage.h | ||
| Save the object and attachments into the archive as a stream of compact binary fields. | Serialization/CompactBinaryPackage.h | ||
| Set the root object without gathering attachments. | Serialization/CompactBinaryPackage.h | ||
| Set the root object and gather attachments using the resolver. | Serialization/CompactBinaryPackage.h | ||
| Set the root object without gathering attachments. | Serialization/CompactBinaryPackage.h | ||
| Set the root object and gather attachments using the resolver. | Serialization/CompactBinaryPackage.h | ||
bool TryLoad
(
FCbFieldIterator& Fields |
Load the object and attachments from compact binary as written by Save. | Serialization/CompactBinaryPackage.h | |
| Load the object and attachments from compact binary as written by Save. | Serialization/CompactBinaryPackage.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
operator bool() |
Whether the package has a non-empty object or attachments. | Serialization/CompactBinaryPackage.h | |
bool operator!=
(
const FCbPackage& Package |
Serialization/CompactBinaryPackage.h | ||
bool operator==
(
const FCbPackage& Package |
Serialization/CompactBinaryPackage.h |