From ae5db7ee201f131efa4d755b36f0fe4e4ec0f0a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lazar=20Prijovi=C4=87?= Date: Fri, 27 Aug 2021 07:55:10 +0300 Subject: [PATCH] [cpp-ue4] Add missing convertors for arbitrary-typed variables (#10276) * Add missing convertors for TSharedPtr * Update samples --- .../resources/cpp-ue4/helpers-header.mustache | 19 +++++++++++++++++++ .../petstore/cpp-ue4/Public/OpenAPIHelpers.h | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache b/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache index c584eadee58..640db9da815 100644 --- a/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache +++ b/modules/openapi-generator/src/main/resources/cpp-ue4/helpers-header.mustache @@ -212,6 +212,19 @@ inline FString CollectionToUrlString_multi(const TArray& Collection, const TC ////////////////////////////////////////////////////////////////////////// +inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr& Value) +{ + if (Value.IsValid()) + { + FJsonSerializer::Serialize(Value.ToSharedRef(), "", Writer, false); + } + else + { + Writer->WriteObjectStart(); + Writer->WriteObjectEnd(); + } +} + inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr& Value) { if (Value.IsValid()) @@ -324,6 +337,12 @@ inline bool TryGetJsonValue(const TSharedPtr& JsonValue, bool& Value return false; } +inline bool TryGetJsonValue(const TSharedPtr& JsonValue, TSharedPtr& JsonObjectValue) +{ + JsonObjectValue = JsonValue; + return true; +} + inline bool TryGetJsonValue(const TSharedPtr& JsonValue, TSharedPtr& JsonObjectValue) { const TSharedPtr* Object; diff --git a/samples/client/petstore/cpp-ue4/Public/OpenAPIHelpers.h b/samples/client/petstore/cpp-ue4/Public/OpenAPIHelpers.h index 606e1e9851c..ff8497f23f9 100644 --- a/samples/client/petstore/cpp-ue4/Public/OpenAPIHelpers.h +++ b/samples/client/petstore/cpp-ue4/Public/OpenAPIHelpers.h @@ -221,6 +221,19 @@ inline FString CollectionToUrlString_multi(const TArray& Collection, const TC ////////////////////////////////////////////////////////////////////////// +inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr& Value) +{ + if (Value.IsValid()) + { + FJsonSerializer::Serialize(Value.ToSharedRef(), "", Writer, false); + } + else + { + Writer->WriteObjectStart(); + Writer->WriteObjectEnd(); + } +} + inline void WriteJsonValue(JsonWriter& Writer, const TSharedPtr& Value) { if (Value.IsValid()) @@ -333,6 +346,12 @@ inline bool TryGetJsonValue(const TSharedPtr& JsonValue, bool& Value return false; } +inline bool TryGetJsonValue(const TSharedPtr& JsonValue, TSharedPtr& JsonObjectValue) +{ + JsonObjectValue = JsonValue; + return true; +} + inline bool TryGetJsonValue(const TSharedPtr& JsonValue, TSharedPtr& JsonObjectValue) { const TSharedPtr* Object;