Files
UnrealEngineUWP/Engine/Source/Runtime/Serialization/Public/Backends/JsonStructDeserializerBackend.h
ryan durand 0f0464a30e Updating copyright for Engine Runtime.
#rnx
#rb none


#ROBOMERGE-OWNER: ryan.durand
#ROBOMERGE-AUTHOR: ryan.durand
#ROBOMERGE-SOURCE: CL 10869210 via CL 10869511 via CL 10869900
#ROBOMERGE-BOT: (v613-10869866)

[CL 10870549 by ryan durand in Main branch]
2019-12-26 14:45:42 -05:00

70 lines
1.8 KiB
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Serialization/JsonReader.h"
#include "IStructDeserializerBackend.h"
/**
* 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;
};