Files
UnrealEngineUWP/Engine/Source/Runtime/Serialization/Public/Backends/JsonStructDeserializerBackend.h
Bryan sefcik b4a6e947d8 Ran IWYU on Public headers under Engine/Source/Runtime/...
Headers are updated to contain any missing #includes needed to compile and #includes are sorted.  Nothing is removed.

#ushell-cherrypick of 21065896 by bryan.sefcik
#preflight 62d4b1a5a6141b6adfb0c892
#jira

#ROBOMERGE-OWNER: Bryan.sefcik
#ROBOMERGE-AUTHOR: bryan.sefcik
#ROBOMERGE-SOURCE: CL 21150156 via CL 21151754 via CL 21154719
#ROBOMERGE-BOT: UE5 (Release-Engine-Staging -> Main) (v972-20964824)
#ROBOMERGE-CONFLICT from-shelf

[CL 21181076 by Bryan sefcik in ue5-main branch]
2022-07-20 11:31:36 -04:00

77 lines
2.0 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Containers/UnrealString.h"
#include "CoreMinimal.h"
#include "HAL/Platform.h"
#include "IStructDeserializerBackend.h"
#include "Serialization/JsonReader.h"
#include "Serialization/JsonTypes.h"
#include "Templates/SharedPointer.h"
class FArchive;
class FProperty;
/**
* Implements a reader for UStruct deserialization using Json.
*
* Note: The underlying Json de-serializer is currently hard-coded to use UCS2CHAR.
* This is because the current JsonReader API does not allow writers to be substituted since it's
* all based on templates. At some point we will refactor the low-level Json API to provide more
* flexibility for serialization.
*/
class SERIALIZATION_API FJsonStructDeserializerBackend
: public IStructDeserializerBackend
{
public:
/**
* Creates and initializes a new instance.
*
* @param Archive The archive to deserialize from.
*/
FJsonStructDeserializerBackend( FArchive& Archive )
: JsonReader(TJsonReader<UCS2CHAR>::Create(&Archive))
{ }
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 void SkipArray() override;
virtual void SkipStructure() override;
protected:
FString& GetLastIdentifier()
{
return LastIdentifier;
}
EJsonNotation GetLastNotation()
{
return LastNotation;
}
TSharedRef<TJsonReader<UCS2CHAR>>& GetReader()
{
return JsonReader;
}
private:
/** Holds the name of the last read Json identifier. */
FString LastIdentifier;
/** Holds the last read Json notation. */
EJsonNotation LastNotation;
/** Holds the Json reader used for the actual reading of the archive. */
TSharedRef<TJsonReader<UCS2CHAR>> JsonReader;
};