Projekt for SPIE - Avatar for safety briefing / managment event
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

68 lines
2.3 KiB

// Copyright 2022 Danyang Chen https://github.com/DAN-AND-DNA
#pragma once
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Runtime/Launch/Resources/Version.h"
#include "Struct2JsonLibrary.generated.h"
UCLASS()
class UWrapperStructProperty : public UObject {
GENERATED_BODY()
public:
FStructProperty* InterStruct;
};
UCLASS()
class EASYSTRUCT2JSON_API UStruct2JsonLibaray : public UBlueprintFunctionLibrary {
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "Struct2Json", CustomThunk, meta = (CustomStructureParam = "OutStruct"))
static UPARAM(DisplayName = "Ok") bool Json2Struct(const FString& JsonStr, const int32& OutStruct);
DECLARE_FUNCTION(execJson2Struct) {
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 26 || ENGINE_MAJOR_VERSION > 4)
P_GET_PROPERTY(FStrProperty, JsonStr);
Stack.StepCompiledIn<FStructProperty>(NULL);
FStructProperty* StructProperty = ExactCastField<FStructProperty>(Stack.MostRecentProperty);
void* StructPropertyPtr = Stack.MostRecentPropertyAddress;
P_FINISH;
*(bool*) RESULT_PARAM = JsonStr2Struct(StructProperty, StructPropertyPtr, JsonStr);
#else
*(bool*) RESULT_PARAM = false;
#endif
}
UFUNCTION(BlueprintCallable, Category = "Struct2Json", CustomThunk, meta = (CustomStructureParam = "InStruct"))
static UPARAM(DisplayName = "Ok") bool Struct2Json(const int32& InStruct, FString& JsonStr, bool bPretty = false, bool bOmitEmpty = true);
DECLARE_FUNCTION(execStruct2Json) {
#if (ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 26 || ENGINE_MAJOR_VERSION > 4)
Stack.StepCompiledIn<FStructProperty>(NULL);
FStructProperty* StructProperty = ExactCastField<FStructProperty>(Stack.MostRecentProperty);
void* StructPropertyPtr = Stack.MostRecentPropertyAddress;
P_GET_PROPERTY_REF(FStrProperty, JsonStr);
P_GET_PROPERTY(FBoolProperty, bPretty);
P_GET_PROPERTY(FBoolProperty, bOmitEmpty);
P_FINISH;
*(bool*)RESULT_PARAM = Struct2JsonStr(StructProperty, StructPropertyPtr, JsonStr, bPretty, bOmitEmpty);
#else
*(bool*)RESULT_PARAM = false;
#endif
}
static bool JsonStr2Struct(FStructProperty* StructProperty, void* StructPtr, const FString& InJsonStr);
static bool Struct2JsonStr(FStructProperty* StructProperty, void* StructPtr, FString& OutJsonStr, bool bPretty, bool bOmitEmpty);
};