diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index 9429af304..8d3f80d1f 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -67,6 +67,20 @@ bool Dictionary::Get(const String& key, Value *result) const return true; } +/** + * Retrieves a value's address from a dictionary. + * + * @param key The key whose value's address should be retrieved. + * @returns nullptr if the key was not found. + */ +const Value * Dictionary::GetRef(const String& key) const +{ + std::shared_lock lock (m_DataMutex); + auto it (m_Data.find(key)); + + return it == m_Data.end() ? nullptr : &it->second; +} + /** * Sets a value in the dictionary. * diff --git a/lib/base/dictionary.hpp b/lib/base/dictionary.hpp index 352c29ef9..ffccd630f 100644 --- a/lib/base/dictionary.hpp +++ b/lib/base/dictionary.hpp @@ -42,6 +42,7 @@ public: Value Get(const String& key) const; bool Get(const String& key, Value *result) const; + const Value * GetRef(const String& key) const; void Set(const String& key, Value value, bool overrideFrozen = false); bool Contains(const String& key) const;