Files
UnrealEngineUWP/Engine/Source/Runtime/Serialization/Public/Backends/CborStructDeserializerBackend.h
simon therriault cebbbbf8b3 - Debackout with CIS fix -> Updating MessageBus protocol and CBor serialization backend to support communication between LWC and non LWC endpoints
#rb francis.hurteau, jason.walter
#jira UE-142171
#preflight 62067326ad10bdb30a9f0361
#lockdown alejandro.arango

#ROBOMERGE-AUTHOR: simon.therriault
#ROBOMERGE-SOURCE: CL 18957877 in //UE5/Release-5.0/... via CL 18958785 via CL 18959502
#ROBOMERGE-BOT: UE5 (Release-Engine-Test -> Main) (v917-18934589)

[CL 18959726 by simon therriault in ue5-main branch]
2022-02-11 15:17:57 -05:00

57 lines
2.1 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "CborReader.h"
#include "IStructDeserializerBackend.h"
/**
* Implements a reader for UStruct deserialization using Cbor.
*/
class SERIALIZATION_API FCborStructDeserializerBackend
: public IStructDeserializerBackend
{
public:
/**
* Creates and initializes a new instance.
* @param Archive The archive to deserialize from.
* @param CborDataEndianness The CBOR data endianness stored in the archive.
* @note For backward compatibility and performance, the implementation default to the the platform endianness rather than the CBOR standard one (big endian).
*/
FCborStructDeserializerBackend(FArchive& Archive, ECborEndianness CborDataEndianness = ECborEndianness::Platform, bool bInIsLWCCompatibilityMode = false);
virtual ~FCborStructDeserializerBackend();
public:
// IStructDeserializerBackend interface
virtual const FString& GetCurrentPropertyName() const override;
virtual FString GetDebugString() const override;
virtual const FString& GetLastErrorMessage() const override;
virtual bool GetNextToken(EStructDeserializerBackendTokens& OutToken) override;
virtual bool ReadProperty(FProperty* Property, FProperty* Outer, void* Data, int32 ArrayIndex) override;
virtual bool ReadPODArray(FArrayProperty* ArrayProperty, void* Data) override;
virtual void SkipArray() override;
virtual void SkipStructure() override;
private:
/** Holds the Cbor reader used for the actual reading of the archive. */
FCborReader CborReader;
/** Holds the last read Cbor Context. */
FCborContext LastContext;
/** Holds the last map key. */
FString LastMapKey;
/** The index of the next byte to copy from the CBOR byte stream into the corresponding TArray<uint8>/TArray<int8> property. */
int32 DeserializingByteArrayIndex = 0;
/** Whether a TArray<uint8>/TArray<int8> property is being deserialized. */
bool bDeserializingByteArray = false;
/** Whether we are deserializing for LWC backward compability mode. Incoming FloatProperties of LWC types deserialized into Double */
bool bIsLWCCompatibilityMode = false;
};