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