Files
UnrealEngineUWP/Engine/Source/Runtime/Serialization/Public/Backends/JsonStructSerializerBackend.h
Alex Fennell d10f9953d9 Copying //UE4/Portal-Staging to //UE4/Dev-Main (Source: //UE4/Portal-Staging @ 3138637)
#lockdown Nick.Penwarden, justin.sargent
#rb None

[CL 3138769 by Alex Fennell in Main branch]
2016-09-23 17:31:51 -04:00

60 lines
1.6 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "IStructSerializerBackend.h"
#include "Json.h"
// forward declarations
class UProperty;
class UStruct;
/**
* Implements a writer for UStruct serialization using Json.
*
* Note: The underlying Json serializer is currently hard-coded to use UCS2CHAR and pretty-print.
* This is because the current JsonWriter 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 FJsonStructSerializerBackend
: public IStructSerializerBackend
{
public:
/**
* Creates and initializes a new instance.
*
* @param Archive The archive to serialize into.
*/
FJsonStructSerializerBackend( FArchive& Archive )
: JsonWriter(TJsonWriter<UCS2CHAR>::Create(&Archive))
{ }
public:
// IStructSerializerBackend interface
virtual void BeginArray(const FStructSerializerState& State) override;
virtual void BeginStructure(const FStructSerializerState& State) override;
virtual void EndArray(const FStructSerializerState& State) override;
virtual void EndStructure(const FStructSerializerState& State) override;
virtual void WriteComment(const FString& Comment) override;
virtual void WriteProperty(const FStructSerializerState& State, int32 ArrayIndex = 0) override;
protected:
// Allow access to the internal JsonWriter to subclasses
TSharedRef<TJsonWriter<UCS2CHAR>>& GetWriter()
{
return JsonWriter;
}
private:
/** Holds the Json writer used for the actual serialization. */
TSharedRef<TJsonWriter<UCS2CHAR>> JsonWriter;
};