You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#CodeReview: keli.hlodversson, justin.sargent [CL 2685160 by Max Preussner in Main branch]
52 lines
1.5 KiB
C++
52 lines
1.5 KiB
C++
// Copyright 1998-2015 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;
|
|
|
|
private:
|
|
|
|
/** Holds the Json writer used for the actual serialization. */
|
|
TSharedRef<TJsonWriter<UCS2CHAR>> JsonWriter;
|
|
};
|