Introduce Dictionary#GetRef()

This commit is contained in:
Alexander A. Klimov 2023-08-30 16:34:36 +02:00
parent 2d167ccd28
commit 8bcae97ecc
2 changed files with 15 additions and 0 deletions

View File

@ -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<std::shared_timed_mutex> lock (m_DataMutex);
auto it (m_Data.find(key));
return it == m_Data.end() ? nullptr : &it->second;
}
/**
* Sets a value in the dictionary.
*

View File

@ -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;