25 #ifndef LSST_AFW_TYPEHANDLING_SIMPLEGENERICMAP_H 26 #define LSST_AFW_TYPEHANDLING_SIMPLEGENERICMAP_H 30 #include <unordered_map> 33 #include "boost/variant.hpp" 39 namespace typehandling {
71 _storage = other._storage;
74 swap(_keyView, newKeys);
82 _storage = _convertStorage(other);
84 swap(_keyView, newKeys);
90 bool empty() const noexcept
override {
return _storage.
empty(); }
108 return _storage.
at(key);
111 message <<
"Key not found: " <<
key;
124 swap(_keyView, newKeys);
131 for (
auto it = newKeys.
cbegin(); it != newKeys.
cend();) {
133 it = newKeys.
erase(it);
139 bool erased = _storage.
erase(key) > 0;
142 swap(_keyView, newKeys);
165 map.
apply([&newStorage](K
const&
key,
auto const& value) { newStorage.
emplace(key, value); });
virtual ~SimpleGenericMap() noexcept=default
bool unsafeInsert(K key, StorableType &&value) override
Create a new mapping with key equal to key and value equal to value.
bool unsafeErase(K key) override
Remove the mapping for a key from this map, if it exists.
decltype(_typeToConstRef(std::declval< StorableType >())) ConstValueReference
A type-agnostic reference to the value stored inside the map.
bool empty() const noexcept override
Return true if this map contains no key-value pairs.
boost::variant< bool, std::int32_t, std::int64_t, float, double, std::string, PolymorphicValue, std::shared_ptr< Storable > > StorableType
The types that can be stored in a map.
A base class for image defects.
std::vector< K > const & keys() const noexcept override
Return the set of all keys, without type information.
A GenericMap that allows insertion and deletion of arbitrary values.
T throw_with_nested(T... args)
auto apply(Visitor &&visitor) const
Apply an operation to each key-value pair in the map.
SimpleGenericMap & operator=(SimpleGenericMap const &other)
SimpleGenericMap()=default
#define LSST_EXCEPT(type,...)
Create an exception with a given type.
Reports attempts to access elements outside a valid range of indices.
GenericMap< K >::size_type size() const noexcept override
Return the number of key-value pairs in the map.
bool contains(K const &key) const override
Return true if this map contains a mapping whose key has the specified label.
ConstValueReference unsafeLookup(K key) const override
Return a reference to the mapped value of the element with key equal to key.
void clear() noexcept override
Remove all of the mappings from this map.
void swap(PolymorphicValue &lhs, PolymorphicValue &rhs) noexcept
Swap specialization for PolymorphicValue.
SimpleGenericMap(GenericMap< K > const &other)
Convert another GenericMap into a SimpleGenericMap.
ItemVariant const * other
GenericMap< K >::size_type max_size() const noexcept override
Return the maximum number of elements the container is able to hold due to system or library implemen...
Interface for a GenericMap that allows element addition and removal.
Interface for a heterogeneous map.
SimpleGenericMap & operator=(GenericMap< K > const &other)
T emplace_back(T... args)
virtual std::vector< K > const & keys() const noexcept=0
Return the set of all keys, without type information.