Class MetadataDictionary
- Defined in File metadata.hpp 
- 
class MetadataDictionary
- Class to define a metadata dictionary object. - Public Types - 
using MapType = std::unordered_map<std::string, std::shared_ptr<MetadataObject>>
 - 
using Iterator = MapType::iterator
 - 
using ConstIterator = MapType::const_iterator
 - Public Functions - 
inline explicit MetadataDictionary(const MetadataPolicy &policy = MetadataPolicy::kDefault)
 - 
MetadataDictionary(const MetadataDictionary&) = default
 - 
MetadataDictionary(MetadataDictionary&&) = default
 - 
MetadataDictionary &operator=(const MetadataDictionary&)
 - 
MetadataDictionary &operator=(MetadataDictionary&&) = default
 - 
virtual ~MetadataDictionary() = default
 - 
std::vector<std::string> keys() const
- Get a vector of the keys in the dictionary. 
 - 
std::shared_ptr<MetadataObject> &operator[](const std::string&)
- Provide indexing into the underlying dictionary. 
 - 
const MetadataObject *operator[](const std::string&) const
- Provide indexing into the underlying dictionary. 
 - 
std::shared_ptr<MetadataObject> get(const std::string &key) const
- Get a shared pointer to the MetadataObject corresponding to the provided key. - See the templated variant of get for a version of this method that extracts the std::any value from the MetadataObject and performs the any_cast<ValueT> operation on it. - Parameters
- key – The key for the value to retrieve. 
- Returns
- The value corresponding to the key 
 
 - 
template<typename ValueT>
 inline ValueT get(const std::string &key) const
- Get the value contained in the MetadataObject corresponding to the provided key. - Calling - dict->get<T>(key)is a convenience method for the following:- auto metadata_obj = dict->get(key); auto value = std::any_cast<T>(metadata_obj->value()); - This functions raises a std::runtime_error if the key does not exist. - Template Parameters
- ValueT – The type of data stored in the std::any returned by MetadataObject.value() 
- Parameters
- key – The key for the value to retrieve. 
- Returns
- The value contained in the metadata object corresponding to the key 
 
 - 
template<typename ValueT>
 inline ValueT get(const std::string &key, const ValueT &default_value) const
- Get the value contained in the MetadataObject corresponding to the provided key. - Calling - dict->get<T>(key)is a convenience method for the following:- auto metadata_obj = dict->get(key); auto value = std::any_cast<T>(metadata_obj->value()); - This function returns the provided default_value if the key does not exist - Template Parameters
- ValueT – The type of data stored in the std::any returned by MetadataObject.value() 
- Parameters
- key – The key for the value to insert. 
- default_value – The value to return if the key does not exist in the dictionary 
 
- Returns
- The value contained in the metadata object corresponding to the key 
 
 - Insert a new value at the specified key (or update an existing one) - This method inserts a new item. If the key already exists, this method will have a behavior that depends on the policy ( - MetadataPolicy) set for this dictionary.- For this method, kInplaceUpdate behaves the same as kUpdate. - Parameters
- key – The key for the value to insert (or update). 
- value – The value to store. 
 
 
 - 
template<typename ValueT, typename = std::enable_if_t<!std::is_same_v<std::decay_t<ValueT>, std::shared_ptr<MetadataObject>>>>
 inline void set(const std::string &key, ValueT value)
- Insert or update a value at the specified key. - This method inserts a new item. If the key already exists, this method will have a behavior that depends on the policy ( - MetadataPolicy) set for this dictionary.- Template Parameters
- ValueT – The type of metadata to insert 
- Parameters
- key – The key for the value to insert (or update). 
- value – The value to store. 
 
 
 - 
inline MetadataPolicy policy() const
- Get the metadata policy used by this MetadataDictionary. 
 - 
inline void policy(const MetadataPolicy &metadata_policy)
- Set the metadata policy used by this MetadataDictionary. 
 - 
bool has_key(const std::string &key) const
- Determine if an item already exists in the dictionary. - Parameters
- key – The key for the value to insert (or update). 
- Returns
- Returns true if the key already exists in the dictionary, false otherwise. 
 
 - 
bool erase(const std::string &key)
- Erase an item from the dictionary. - Parameters
- key – The key of the item to erase. 
- Returns
- Returns true if the key was erased and false if the key was not found. 
 
 - 
ConstIterator begin() const
- begin() constiterator of the underlying dictionary 
 - 
ConstIterator end() const
- end() constiterator of the underlying dictionary 
 - 
Iterator find(const std::string &key)
- find() on the underlying dictionary. Returns an iterator to the element if found, else end() 
 - 
ConstIterator find(const std::string &key) const
- find() on the underlying dictionary. Returns an iterator to the element if found, else end() 
 - 
void clear()
- clear all values from the dictionary 
 - 
std::size_t size() const
- return the number of items in the dictionary 
 - 
void swap(MetadataDictionary &other)
- swap the contents of this dictionary and other 
 - 
void merge(MetadataDictionary &other)
- merge (move) the contents of other dictionary into this dictionary 
 - 
void insert(MetadataDictionary &other)
- Insert items the other dictionary into this dictionary. Pre-existing values are not updated. 
 - 
void update(MetadataDictionary &other)
- Update the dictionary with items present in other. - This method will update the dictionary with values from other. If a key already exists in this dictionary, the behavior is determined by the policy (MetadataPolicy) set for this dictionary. - For this method, kInplaceUpdate behaves the same as kUpdate. - Parameters
- other – metadata dictionary to copy items from 
 
 
- 
using MapType = std::unordered_map<std::string, std::shared_ptr<MetadataObject>>