From b038c168c635fedd58bf6f9baffd37ccadf31904 Mon Sep 17 00:00:00 2001 From: Alexander Kromm Date: Thu, 6 Feb 2020 21:20:33 +0700 Subject: [PATCH] aggregate TMap into Dictionary instead of deriving from it --- src/serializer.cpp | 4 ++-- src/utility/dictionary.cpp | 10 +++++----- src/utility/dictionary.h | 10 ++++++++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/serializer.cpp b/src/serializer.cpp index 860dcad2a9..cd9b5b8f22 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -2165,7 +2165,7 @@ template<> FSerializer &Serialize(FSerializer &arc, const char *key, FFont *&fon FString DictionaryToString(const Dictionary &dict) { Dictionary::ConstPair *pair; - Dictionary::ConstIterator i { dict }; + Dictionary::ConstIterator i { dict.Map }; rapidjson::StringBuffer buffer; rapidjson::Writer writer(buffer); @@ -2214,7 +2214,7 @@ Dictionary *DictionaryFromString(const FString &string) return dict; } - dict->Insert(i->name.GetString(), i->value.GetString()); + dict->Map.Insert(i->name.GetString(), i->value.GetString()); } return dict; diff --git a/src/utility/dictionary.cpp b/src/utility/dictionary.cpp index 7e9e14a1f6..a6bcccc663 100644 --- a/src/utility/dictionary.cpp +++ b/src/utility/dictionary.cpp @@ -42,7 +42,7 @@ void Dictionary::Serialize(FSerializer &arc) // Receive new Dictionary, copy contents, clean up. Dictionary *pointerToDeserializedDictionary; arc(key, pointerToDeserializedDictionary); - TransferFrom(*pointerToDeserializedDictionary); + Map.TransferFrom(pointerToDeserializedDictionary->Map); delete pointerToDeserializedDictionary; } } @@ -56,12 +56,12 @@ static Dictionary *DictCreate() static void DictInsert(Dictionary *dict, const FString &key, const FString &value) { - dict->Insert(key, value); + dict->Map.Insert(key, value); } static void DictAt(const Dictionary *dict, const FString &key, FString *result) { - const FString *value = dict->CheckKey(key); + const FString *value = dict->Map.CheckKey(key); *result = value ? *value : ""; } @@ -72,7 +72,7 @@ static void DictToString(const Dictionary *dict, FString *result) static void DictRemove(Dictionary *dict, const FString &key) { - dict->Remove(key); + dict->Map.Remove(key); } //===================================================================================== @@ -150,7 +150,7 @@ void DictionaryIterator::Serialize(FSerializer &arc) void DictionaryIterator::init(Dictionary *dict) { - Iterator = std::make_unique(*dict); + Iterator = std::make_unique(dict->Map); Dict = dict; GC::WriteBarrier(this, Dict); diff --git a/src/utility/dictionary.h b/src/utility/dictionary.h index d97099482a..ef6bd3f682 100644 --- a/src/utility/dictionary.h +++ b/src/utility/dictionary.h @@ -13,13 +13,19 @@ * * It is derived from DObject to be a part of normal GC process. */ -class Dictionary final : public DObject, public TMap +class Dictionary final : public DObject { DECLARE_CLASS(Dictionary, DObject) public: + using StringMap = TMap; + using ConstIterator = StringMap::ConstIterator; + using ConstPair = StringMap::ConstPair; + void Serialize(FSerializer &arc) override; + + StringMap Map; }; /** @@ -45,7 +51,7 @@ public: */ DictionaryIterator(); - void Serialize(FSerializer &arc) override; + void Serialize(FSerializer &arc) override; /** * @brief init function complements constructor.