Files
UnrealEngineUWP/Engine/Source/Runtime/Serialization/Public/Backends/CborStructDeserializerBackend.h
Marc Audy cac1fe0019 Merge UE5/Release-Engine-Staging @ CL# 15299266 to UE5/Main
This represents UE4/Main @ CL# 15277572

[CL 15299962 by Marc Audy in ue5-main branch]
2021-02-03 14:57:28 -04:00

54 lines
1.9 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);
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;
};