5#include "CoreMinimal.h"
6#include "Templates/SharedPointer.h"
7#include "Dom/JsonValue.h"
9#include "XAPIExtension.generated.h"
16 TMap<FString, TSharedPtr<FJsonValue>> Fields;
23 Fields.Append(InExtension.Fields);
32 Fields.Append(InExtension.
Fields);
42 TSharedPtr<FJsonValue>& AddString(FString InKey,
const FString& InValue)
45 return Add(InKey, ValuePtr);
48 TSharedPtr<FJsonValue>& AddCustomString(FString InKey,
const FString& InValue)
51 return AddCustom(InKey, ValuePtr);
55 TSharedPtr<FJsonValue>& AddNumber(FString InKey,
const int& InValue)
58 return Add(InKey, ValuePtr);
61 TSharedPtr<FJsonValue>& AddCustomNumber(FString InKey,
const int& InValue)
64 return AddCustom(InKey, ValuePtr);
68 TSharedPtr<FJsonValue>& AddBoolean(FString InKey,
const bool& InValue)
71 return Add(InKey, ValuePtr);
74 TSharedPtr<FJsonValue>& AddCustomBoolean(FString InKey,
const bool& InValue)
77 return AddCustom(InKey, ValuePtr);
81 TSharedPtr<FJsonValue>& Add(FString InKey,
const TSharedPtr<FJsonValue>& InValue)
83 return Fields.Add(
"https://pixovr.com/xapi/extension/" + InKey, InValue);
86 TSharedPtr<FJsonValue>& AddCustom(FString InKey,
const TSharedPtr<FJsonValue>& InValue)
88 return Fields.Add(InKey, InValue);
91 virtual bool IsEmpty()
const override
93 return Fields.Num() == 0;
96 virtual TSharedPtr<FJsonObject>
ToJsonObject()
const override
98 TSharedPtr<FJsonObject> Result(
new FJsonObject);
100 for (
const TPair<FString, TSharedPtr<FJsonValue>>& Pair : Fields)
102 Result->SetField(Pair.Key, Pair.Value);
virtual TSharedPtr< FJsonObject > ToJsonObject() const
virtual bool IsEmpty() const
TSharedPtr< FJsonValue > & AddCustomBoolean(FString InKey, const bool &InValue)
virtual ~FXAPIExtension()
TSharedPtr< FJsonValue > & Add(FString InKey, const TSharedPtr< FJsonValue > &InValue)
void Clone(const FXAPIExtension &InExtension)
TSharedPtr< FJsonValue > & AddString(FString InKey, const FString &InValue)
TSharedPtr< FJsonValue > & AddCustom(FString InKey, const TSharedPtr< FJsonValue > &InValue)
TMap< FString, TSharedPtr< FJsonValue > > Fields
FXAPIExtension(const FXAPIExtension &InExtension)
TSharedPtr< FJsonValue > & AddCustomString(FString InKey, const FString &InValue)
TSharedPtr< FJsonValue > & AddNumber(FString InKey, const int &InValue)
TSharedPtr< FJsonValue > & AddBoolean(FString InKey, const bool &InValue)
FXAPIExtension & operator=(const FXAPIExtension &InExtension)
TSharedPtr< FJsonValue > & AddCustomNumber(FString InKey, const int &InValue)
virtual bool IsEmpty() const override
virtual TSharedPtr< FJsonObject > ToJsonObject() const override