UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CompactBinarySerialization.cpp File Reference
#include "Serialization/CompactBinarySerialization.h"
#include "Containers/Array.h"
#include "Containers/ContainerAllocationPolicies.h"
#include "Containers/SharedString.h"
#include "Containers/StringView.h"
#include "Containers/Utf8String.h"
#include "Containers/UnrealString.h"
#include "CoreGlobals.h"
#include "HAL/PlatformString.h"
#include "Logging/LogMacros.h"
#include "Memory/MemoryView.h"
#include "Misc/AsciiSet.h"
#include "Misc/AssertionMacros.h"
#include "Misc/Base64.h"
#include "Misc/DateTime.h"
#include "Misc/Guid.h"
#include "Misc/StringBuilder.h"
#include "Misc/Timespan.h"
#include "Serialization/Archive.h"
#include "Serialization/CompactBinaryValidation.h"
#include "Serialization/CompactBinaryValue.h"
#include "Serialization/VarInt.h"
#include "Templates/Function.h"
#include "Templates/IdentityFunctor.h"
#include "Templates/Invoke.h"
#include "Templates/RemoveReference.h"
#include "Templates/UnrealTemplate.h"
#include "UObject/NameTypes.h"

Classes

struct  UE::Serialization::Private::TCbJsonWriterConstants< ANSICHAR >
 
struct  UE::Serialization::Private::TCbJsonWriterConstants< WIDECHAR >
 
struct  UE::Serialization::Private::TCbJsonWriterConstants< UTF8CHAR >
 
class  TCbJsonWriter< CharType >
 

Namespaces

namespace  UE
 
namespace  UE::Serialization
 
namespace  UE::Serialization::Private
 

Functions

template<typename CharType >
void UE::Serialization::Private::AppendQuotedJsonString (TStringBuilderBase< CharType > &Builder, FUtf8StringView Value)
 
template void UE::Serialization::Private::AppendQuotedJsonString< UTF8CHAR > (FUtf8StringBuilderBase &Builder, FUtf8StringView Value)
 
template void UE::Serialization::Private::AppendQuotedJsonString< WIDECHAR > (FWideStringBuilderBase &Builder, FUtf8StringView Value)
 
void UE::Serialization::Private::LogFieldTooLargeForArrayWarning (uint64 FieldLength)
 
uint64 MeasureCompactBinary (FMemoryView View, ECbFieldType Type)
 
bool TryMeasureCompactBinary (FMemoryView View, ECbFieldType &OutType, uint64 &OutSize, ECbFieldType Type)
 
FCbField LoadCompactBinary (FArchive &Ar, FCbBufferAllocator Allocator)
 
void SaveCompactBinary (FArchive &Ar, const FCbFieldView &Field)
 
void SaveCompactBinary (FArchive &Ar, const FCbArrayView &Array)
 
void SaveCompactBinary (FArchive &Ar, const FCbObjectView &Object)
 
FArchiveoperator<< (FArchive &Ar, FCbField &Field)
 
FArchiveoperator<< (FArchive &Ar, FCbArray &Array)
 
FArchiveoperator<< (FArchive &Ar, FCbObject &Object)
 
bool LoadFromCompactBinary (FCbFieldView Field, FUtf8StringBuilderBase &OutValue)
 
bool LoadFromCompactBinary (FCbFieldView Field, FWideStringBuilderBase &OutValue)
 
bool LoadFromCompactBinary (FCbFieldView Field, UE::FUtf8SharedString &OutString)
 
bool LoadFromCompactBinary (FCbFieldView Field, UE::FWideSharedString &OutString)
 
bool LoadFromCompactBinary (FCbFieldView Field, FUtf8String &OutValue)
 
bool LoadFromCompactBinary (FCbFieldView Field, FWideString &OutValue)
 
bool LoadFromCompactBinary (FCbFieldView Field, FName &OutValue)
 
bool LoadFromCompactBinary (FCbFieldView Field, FGuid &OutValue)
 
bool LoadFromCompactBinary (FCbFieldView Field, FGuid &OutValue, const FGuid &Default)
 
bool LoadFromCompactBinary (FCbFieldView Field, FDateTime &OutValue)
 
bool LoadFromCompactBinary (FCbFieldView Field, FDateTime &OutValue, FDateTime Default)
 
void CompactBinaryToJson (const FCbFieldView &Field, FUtf8StringBuilderBase &Builder)
 
void CompactBinaryToJson (const FCbFieldView &Field, FWideStringBuilderBase &Builder)
 
void CompactBinaryToJson (const FCbArrayView &Array, FUtf8StringBuilderBase &Builder)
 
void CompactBinaryToJson (const FCbArrayView &Array, FWideStringBuilderBase &Builder)
 
void CompactBinaryToJson (const FCbObjectView &Object, FUtf8StringBuilderBase &Builder)
 
void CompactBinaryToJson (const FCbObjectView &Object, FWideStringBuilderBase &Builder)
 
void CompactBinaryToCompactJson (const FCbFieldView &Field, FUtf8StringBuilderBase &Builder)
 
void CompactBinaryToCompactJson (const FCbFieldView &Field, FWideStringBuilderBase &Builder)
 
void CompactBinaryToCompactJson (const FCbArrayView &Array, FUtf8StringBuilderBase &Builder)
 
void CompactBinaryToCompactJson (const FCbArrayView &Array, FWideStringBuilderBase &Builder)
 
void CompactBinaryToCompactJson (const FCbObjectView &Object, FUtf8StringBuilderBase &Builder)
 
void CompactBinaryToCompactJson (const FCbObjectView &Object, FWideStringBuilderBase &Builder)
 

Function Documentation

◆ CompactBinaryToCompactJson() [1/6]

void CompactBinaryToCompactJson ( const FCbArrayView Array,
FUtf8StringBuilderBase Builder 
)

◆ CompactBinaryToCompactJson() [2/6]

void CompactBinaryToCompactJson ( const FCbArrayView Array,
FWideStringBuilderBase Builder 
)

◆ CompactBinaryToCompactJson() [3/6]

void CompactBinaryToCompactJson ( const FCbFieldView Field,
FUtf8StringBuilderBase Builder 
)

Convert the compact binary to JSON in a compact format with no added whitespace.

◆ CompactBinaryToCompactJson() [4/6]

void CompactBinaryToCompactJson ( const FCbFieldView Field,
FWideStringBuilderBase Builder 
)

◆ CompactBinaryToCompactJson() [5/6]

void CompactBinaryToCompactJson ( const FCbObjectView Object,
FUtf8StringBuilderBase Builder 
)

◆ CompactBinaryToCompactJson() [6/6]

void CompactBinaryToCompactJson ( const FCbObjectView Object,
FWideStringBuilderBase Builder 
)

◆ CompactBinaryToJson() [1/6]

void CompactBinaryToJson ( const FCbArrayView Array,
FUtf8StringBuilderBase Builder 
)

◆ CompactBinaryToJson() [2/6]

void CompactBinaryToJson ( const FCbArrayView Array,
FWideStringBuilderBase Builder 
)

◆ CompactBinaryToJson() [3/6]

void CompactBinaryToJson ( const FCbFieldView Field,
FUtf8StringBuilderBase Builder 
)

Convert the compact binary to JSON in a multi-line format with indentation.

◆ CompactBinaryToJson() [4/6]

void CompactBinaryToJson ( const FCbFieldView Field,
FWideStringBuilderBase Builder 
)

◆ CompactBinaryToJson() [5/6]

void CompactBinaryToJson ( const FCbObjectView Object,
FUtf8StringBuilderBase Builder 
)

◆ CompactBinaryToJson() [6/6]

void CompactBinaryToJson ( const FCbObjectView Object,
FWideStringBuilderBase Builder 
)

◆ LoadCompactBinary()

FCbField LoadCompactBinary ( FArchive Ar,
FCbBufferAllocator  Allocator = FUniqueBuffer::Alloc 
)

Load a compact binary field from an archive.

The field may be an array or an object, which the caller can convert to by using AsArray or AsObject as appropriate. The buffer allocator is called to provide the buffer for the field to load into once its size has been determined.

Parameters
ArArchive to read the field from. An error state is set on failure.
AllocatorAllocator for the buffer that the field is loaded into.
Returns
A field with a reference to the allocated buffer, or a default field on failure.

◆ LoadFromCompactBinary() [1/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
FDateTime OutValue 
)

◆ LoadFromCompactBinary() [2/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
FDateTime OutValue,
FDateTime  Default 
)

◆ LoadFromCompactBinary() [3/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
FGuid OutValue 
)

◆ LoadFromCompactBinary() [4/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
FGuid OutValue,
const FGuid Default 
)

◆ LoadFromCompactBinary() [5/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
FName OutValue 
)

◆ LoadFromCompactBinary() [6/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
FUtf8String OutValue 
)

◆ LoadFromCompactBinary() [7/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
FUtf8StringBuilderBase OutValue 
)

LoadFromCompactBinary attempts to load the output value from compact binary.

Implementations of LoadCompactBinary are expected to assign the output even on failure. Implementations may accept an optional default value to assign in case of load failure.

Returns
true if required fields had the values with the correct type and range, otherwise false.

◆ LoadFromCompactBinary() [8/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
FWideString OutValue 
)

◆ LoadFromCompactBinary() [9/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
FWideStringBuilderBase OutValue 
)

◆ LoadFromCompactBinary() [10/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
UE::FUtf8SharedString OutString 
)

◆ LoadFromCompactBinary() [11/11]

bool LoadFromCompactBinary ( FCbFieldView  Field,
UE::FWideSharedString OutString 
)

◆ MeasureCompactBinary()

uint64 MeasureCompactBinary ( FMemoryView  View,
ECbFieldType  Type = ECbFieldType::HasFieldType 
)

Determine the size in bytes of the compact binary field at the start of the view.

This may be called on an incomplete or invalid field, in which case the returned size is zero. A size can always be extracted from a valid field with no name if a view of at least the first 10 bytes is provided, regardless of field size. For fields with names, the size of view needed to calculate a size is at most 10 + MaxNameLen + MeasureVarUInt(MaxNameLen).

This function can be used when streaming a field, for example, to determine the size of buffer to fill before attempting to construct a field from it.

Parameters
ViewA memory view that may contain the start of a field.
TypeHasFieldType means that View contains the type. Otherwise, use the given type.

◆ operator<<() [1/3]

FArchive & operator<< ( FArchive Ar,
FCbArray Array 
)

◆ operator<<() [2/3]

FArchive & operator<< ( FArchive Ar,
FCbField Field 
)

Serialize a compact binary value to/from an archive.

◆ operator<<() [3/3]

FArchive & operator<< ( FArchive Ar,
FCbObject Object 
)

◆ SaveCompactBinary() [1/3]

void SaveCompactBinary ( FArchive Ar,
const FCbArrayView Array 
)

◆ SaveCompactBinary() [2/3]

void SaveCompactBinary ( FArchive Ar,
const FCbFieldView Field 
)

Save a compact binary value to an archive.

◆ SaveCompactBinary() [3/3]

void SaveCompactBinary ( FArchive Ar,
const FCbObjectView Object 
)

◆ TryMeasureCompactBinary()

bool TryMeasureCompactBinary ( FMemoryView  InView,
ECbFieldType OutType,
uint64 OutSize,
ECbFieldType  InType = ECbFieldType::HasFieldType 
)

Try to determine the type and size of the compact binary field at the start of the view.

This may be called on an incomplete or invalid field, in which case it will return false, with OutSize being 0 for invalid fields, otherwise the minimum view size necessary to make progress in measuring the field on the next call to this function.

Note
A return of true from this function does not indicate that the entire field is valid.
Parameters
InViewA memory view that may contain the start of a field.
OutTypeThe type (with flags) of the field. None is written until a value is available.
OutSizeThe total field size for a return of true, 0 for invalid fields, or the size to make progress in measuring the field on the next call to this function.
InTypeHasFieldType means that InView contains the type. Otherwise, use the given type.
Returns
true if the size of the field was determined, otherwise false.