2019-12-26 14:45:42 -05:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
2016-07-06 22:10:20 -04:00
|
|
|
|
|
|
|
|
#include "JsonObjectWrapper.h"
|
Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none
==========================
MAJOR FEATURES + CHANGES
==========================
Change 3209340 on 2016/11/23 by Ben.Marsh
Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.
Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.
* Every header now includes everything it needs to compile.
* There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
* There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
* Every .cpp file includes its matching .h file first.
* This helps validate that each header is including everything it needs to compile.
* No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
* You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
* There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
* No engine code explicitly includes a precompiled header any more.
* We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
* PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.
Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.
[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00
|
|
|
#include "Policies/CondensedJsonPrintPolicy.h"
|
|
|
|
|
#include "Serialization/JsonReader.h"
|
|
|
|
|
#include "Serialization/JsonSerializer.h"
|
2016-07-06 22:10:20 -04:00
|
|
|
|
2022-02-02 07:59:56 -05:00
|
|
|
FJsonObjectWrapper::FJsonObjectWrapper()
|
|
|
|
|
{
|
|
|
|
|
JsonObject = MakeShared<FJsonObject>();
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-06 22:10:20 -04:00
|
|
|
bool FJsonObjectWrapper::ImportTextItem(const TCHAR*& Buffer, int32 PortFlags, UObject* Parent, FOutputDevice* ErrorText)
|
|
|
|
|
{
|
|
|
|
|
// read JSON string from Buffer
|
|
|
|
|
FString Json;
|
|
|
|
|
if (*Buffer == TCHAR('"'))
|
|
|
|
|
{
|
|
|
|
|
int32 NumCharsRead = 0;
|
|
|
|
|
if (!FParse::QuotedString(Buffer, Json, &NumCharsRead))
|
|
|
|
|
{
|
2022-03-04 11:11:37 -05:00
|
|
|
if (ErrorText)
|
|
|
|
|
{
|
|
|
|
|
ErrorText->Logf(ELogVerbosity::Warning, TEXT("FJsonObjectWrapper::ImportTextItem: Bad quoted string: %s\n"), Buffer);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-06 22:10:20 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
Buffer += NumCharsRead;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// consume the rest of the string (this happens on Paste)
|
|
|
|
|
Json = Buffer;
|
|
|
|
|
Buffer += Json.Len();
|
|
|
|
|
}
|
|
|
|
|
|
2022-02-02 07:59:56 -05:00
|
|
|
// empty string resets/re-initializes shared pointer
|
2016-07-06 22:10:20 -04:00
|
|
|
if (Json.IsEmpty())
|
|
|
|
|
{
|
|
|
|
|
JsonString.Empty();
|
2022-02-02 07:59:56 -05:00
|
|
|
JsonObject = MakeShared<FJsonObject>();
|
2016-07-06 22:10:20 -04:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// parse the json
|
2019-11-21 17:21:11 -05:00
|
|
|
if (!JsonObjectFromString(Json))
|
2016-07-06 22:10:20 -04:00
|
|
|
{
|
|
|
|
|
if (ErrorText)
|
|
|
|
|
{
|
|
|
|
|
ErrorText->Logf(ELogVerbosity::Warning, TEXT("FJsonObjectWrapper::ImportTextItem - Unable to parse json: %s\n"), *Json);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
JsonString = Json;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FJsonObjectWrapper::ExportTextItem(FString& ValueStr, FJsonObjectWrapper const& DefaultValue, UObject* Parent, int32 PortFlags, UObject* ExportRootScope) const
|
|
|
|
|
{
|
|
|
|
|
// empty pointer yields empty string
|
|
|
|
|
if (!JsonObject.IsValid())
|
|
|
|
|
{
|
|
|
|
|
ValueStr.Empty();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// serialize the json
|
2019-11-21 17:21:11 -05:00
|
|
|
return JsonObjectToString(ValueStr);
|
2016-07-06 22:10:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FJsonObjectWrapper::PostSerialize(const FArchive& Ar)
|
|
|
|
|
{
|
Copying //UE4/WEX-Staging/... to //UE4/Main (Source: //WEX/Main @ 3580612)
#rb none
#lockdown nick.penwarden
=================================================================================================
MAJOR FEATURES + CHANGES
=================================================================================================
Change 3526838 by David.Nikdel
#WEX: make map elements support TitleProperty on their values in the editor
#JIRA: none
Change 3517937 by Ben.Zeigler
#jira UE-46574 Deprecate IPlatformChunkInstall::SetChunkInstallDelgate as it was spelled wrong, was only half implemented, and did not support success vs failure
Replace with AddChunkInstallDelegate, which supports a bool error code and is bound once instead of separately for each chunk. All implementations support this delegate at a basic level, although several could be improved to call the failure delegate in more cases
Change 3498765 by David.Nikdel
#WEX: Added a way to bind a delegate that fires whenever an analytics event is queued.
- Bind this delegate and use it to log analytics events (for now)
#JIRA: none
Change 3495796 by Josh.May
#WEX
#JIRA: None
- Reworked the LoadTimes.DumpReport console command to accept command arguments and added options for alphanumeric sorting (-alphasort), tweakable asset time cutoff (lowtime=X), and file output to the Saved/Profiling directory (file).
- Added hooks for automatically generating load time reports for every map load (enabled using the DUMP_LOAD_REPORT_PER_MAP #define).
Change 3489241 by Josh.Markiewicz
#UE4 - First unfinished pass to GoogleIOS
- SDK auth token data needs to copy auth into TMap properly
#jira none
Change 3487767 by David.Nikdel
#Analytics: Make FAnalyticsEventAttribute support typed values
- This makes sure the value types in the resultant JSON reflect the code.
- Added support for Number (double), Boolean, Null, and JsonFragment types
- This should make it so we don't have to whitelist everything to be converted to number on the Grafana processing side.
- Made all attributes on FAnalyticsEventAttribute immutable
#JIRA: WEX-6696, WEX-6706
Change 3478818 by Chris.Babcock
Add detection of Houdini (running on Intel Android CPU)
#jira WEX-5009
#ue4
#android
#robomerge R1.2
Change 3475449 by Allan.Bentham
Add disable force inline option for iOS build, enabled for WEX.
#jira UEMOB-167
[CL 3588553 by Peter Sauerbrei in Main branch]
2017-08-15 16:16:21 -04:00
|
|
|
if (!JsonString.IsEmpty())
|
2016-07-06 22:10:20 -04:00
|
|
|
{
|
|
|
|
|
// try to parse JsonString
|
2019-11-21 17:21:11 -05:00
|
|
|
if (!JsonObjectFromString(JsonString))
|
2016-07-06 22:10:20 -04:00
|
|
|
{
|
|
|
|
|
// do not abide a string that won't parse
|
|
|
|
|
JsonString.Empty();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-21 17:21:11 -05:00
|
|
|
|
2022-02-02 07:59:56 -05:00
|
|
|
FJsonObjectWrapper::operator bool() const
|
|
|
|
|
{
|
|
|
|
|
return JsonObject.IsValid() && !JsonObject->Values.IsEmpty();
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-21 17:21:11 -05:00
|
|
|
bool FJsonObjectWrapper::JsonObjectToString(FString& Str) const
|
|
|
|
|
{
|
|
|
|
|
TSharedRef<TJsonWriter<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>> JsonWriter = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>::Create(&Str, 0);
|
|
|
|
|
return FJsonSerializer::Serialize(JsonObject.ToSharedRef(), JsonWriter, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FJsonObjectWrapper::JsonObjectFromString(const FString& Str)
|
|
|
|
|
{
|
|
|
|
|
TSharedRef<TJsonReader<>> JsonReader = TJsonReaderFactory<>::Create(Str);
|
|
|
|
|
return FJsonSerializer::Deserialize(JsonReader, JsonObject);
|
|
|
|
|
}
|
|
|
|
|
|