# LazyStringMap.hpp
This File On Github
Ask A Question
API: latest
module: oatpp
#include "oatpp/core/data/share/LazyStringMap.hpp"
# LazyStringMapTemplate
Lazy String Map keeps keys, and values as memory label. Once value is requested by user, the new memory block is allocated and value is copied to be stored permanently.
- @tparam Key - one of: oatpp::data::share::MemoryLabel, oatpp::data::share::StringKeyLabel, oatpp::data::share::StringKeyLabelCI, oatpp::data::share::StringKeyLabelCI.
namespace oatpp { namespace data { namespace share {
template<typename Key, typename MapType>
class LazyStringMapTemplate {}
}}}
# Methods
Return Type | Name | Summary |
---|---|---|
[none] | LazyStringMapTemplate | Multiple implementations:
|
void | put | Put value to map. |
void | put_LockFree | Put value to map. Not thread-safe. |
bool | putIfNotExists | Put value to map if not already exists. |
bool | putIfNotExists_LockFree | Put value to map if not already exists. Not thread-safe. |
bool | putOrReplace | Erases all occurrences of key and replaces them with a new entry |
bool | putOrReplace_LockFree | Erases all occurrences of key and replaces them with a new entry. Not thread-safe. |
String | get | Get value as oatpp::String. |
T | getAsMemoryLabel | Get value as a memory label. |
T | getAsMemoryLabel_Unsafe | Get value as a memory label without allocating memory for value. |
const MapType& | getAll | Get map of all values. |
const MapType& | getAll_Unsafe | Get map of all values without allocating memory for those keys/values. |
v_int32 | getSize | Get number of entries in the map. |
# LazyStringMapTemplate::LazyStringMapTemplate
- Constructor.
LazyStringMapTemplate() : m_fullyInitialized(true)
- Copy-constructor.
- @param other
LazyStringMapTemplate(const LazyStringMapTemplate& other)
- Move constructor.
- @param other
LazyStringMapTemplate(LazyStringMapTemplate&& other)
# LazyStringMapTemplate::put
Put value to map.
- @param key
- @param value
void put(const Key& key, const StringKeyLabel& value)
# LazyStringMapTemplate::put_LockFree
Put value to map. Not thread-safe.
- @param key
- @param value
void put_LockFree(const Key& key, const StringKeyLabel& value)
# LazyStringMapTemplate::putIfNotExists
Put value to map if not already exists.
- @param key
- @param value
- @return
bool putIfNotExists(const Key& key, const StringKeyLabel& value)
# LazyStringMapTemplate::putIfNotExists_LockFree
Put value to map if not already exists. Not thread-safe.
- @param key
- @param value
- @return
bool putIfNotExists_LockFree(const Key& key, const StringKeyLabel& value)
# LazyStringMapTemplate::putOrReplace
Erases all occurrences of key and replaces them with a new entry
- @param key
- @param value
- @return - true if an entry was replaced, false if entry was only inserted.
bool putOrReplace(const Key& key, const StringKeyLabel& value)
# LazyStringMapTemplate::putOrReplace_LockFree
Erases all occurrences of key and replaces them with a new entry. Not thread-safe.
- @param key
- @param value
- @return -
true
if an entry was replaced,false
if entry was only inserted.
bool putOrReplace_LockFree(const Key& key, const StringKeyLabel& value)
# LazyStringMapTemplate::get
Get value as oatpp::String.
- @param key
- @return
String get(const Key& key) const
# LazyStringMapTemplate::getAsMemoryLabel
Get value as a memory label.
- @tparam T - one of: oatpp::data::share::MemoryLabel, oatpp::data::share::StringKeyLabel, oatpp::data::share::StringKeyLabelCI.
- @param key
- @return
template<class T>
T getAsMemoryLabel(const Key& key) const
# LazyStringMapTemplate::getAsMemoryLabel_Unsafe
Get value as a memory label without allocating memory for value.
- @tparam T - one of: oatpp::data::share::MemoryLabel, oatpp::data::share::StringKeyLabel, oatpp::data::share::StringKeyLabelCI, * oatpp::data::share::StringKeyLabelCI.
- @param key
- @return
template<class T>
T getAsMemoryLabel_Unsafe(const Key& key) const
# LazyStringMapTemplate::getAll
Get map of all values.
- @return
const MapType& getAll() const
# LazyStringMapTemplate::getAll_Unsafe
Get map of all values without allocating memory for those keys/values.
- @return
const MapType& getAll_Unsafe() const
# LazyStringMapTemplate::getSize
Get number of entries in the map.
- @return
v_int32 getSize() const
# LazyStringMap
Namespace: oatpp::data::share
Convenience template for LazyStringMapTemplate. Based on std::unordered_map
.
template<typename Key, typename Value = StringKeyLabel>
using LazyStringMap = LazyStringMapTemplate<Key, std::unordered_map<Key, Value>>
# LazyStringMultimap
Namespace: oatpp::data::share
Convenience template for LazyStringMapTemplate. Based on std::unordered_map
.
template<typename Key, typename Value = StringKeyLabel>
using LazyStringMultimap = LazyStringMapTemplate<Key, std::unordered_multimap<Key, Value>>