class dlstreamer::BaseDictionary#
Overview#
#include <dictionary.h> class BaseDictionary: public dlstreamer::Dictionary { public: // construction BaseDictionary(); BaseDictionary(std::string_view name); BaseDictionary(const AnyMap& map); BaseDictionary(const std::string& name, const AnyMap& map); // methods virtual std::string name() const; virtual std::optional<Any> try_get(std::string_view key) const; virtual std::pair<const void*, size_t> try_get_array(std::string_view key) const; virtual void set(std::string_view key, Any value); virtual void set_array(std::string_view key, const void* data, size_t nbytes); virtual void set_name(std::string const& name); virtual std::vector<std::string> keys() const; bool operator < (const BaseDictionary& r) const; };
Inherited Members#
public: // methods virtual std::string name() const = 0; virtual std::vector<std::string> keys() const = 0; virtual std::optional<Any> try_get(std::string_view key) const = 0; virtual std::pair<const void*, size_t> try_get_array(std::string_view key) const = 0; virtual void set(std::string_view key, Any value) = 0; virtual void set_array(std::string_view key, const void* data, size_t nbytes) = 0; virtual void set_name(std::string const& name) = 0; template <typename T> T get(std::string_view key) const; template <typename T> T get(std::string_view key, T default_value) const; template <class T> const std::vector<T> get_array(std::string_view key) const;
Detailed Documentation#
Methods#
virtual std::string name() const
Returns dictionary name. Utility function find_metadata uses it to find metadata by specified name.
virtual std::optional<Any> try_get(std::string_view key) const
Returns dictionary element by key. If no handle with the specified key, returns empty std::optional.
Parameters:
key |
the key of the dictionary element to find |
virtual std::pair<const void*, size_t> try_get_array(std::string_view key) const
Returns memory buffer stored in dictionary. The first element of returned std::pair is pointer to memory buffer, second element is buffer size in bytes. If no buffer with the specified key, returns {nullptr,0}.
Parameters:
key |
the key of the memory buffer to find |
virtual void set(std::string_view key, Any value)
Adds element into the dictionary. If the dictionary already contains an element with specified key, the existing value will be overwritten.
Parameters:
key |
the key of the element to add |
value |
the value of the element to add |
virtual void set_array(std::string_view key, const void* data, size_t nbytes)
Allocates memory buffer and copies data from buffer specified in function parameters, and adds memory buffer to the dictionary. If the dictionary already contains an buffer with specified key, the existing buffer will be overwritten.
Parameters:
key |
the key of the memory buffer to add |
data |
pointer to the memory buffer to add |
nbytes |
size (in bytes) of the memory buffer to add |
virtual void set_name(std::string const& name)
Sets name of dictionary. The existing name will be overwritten.
Parameters:
name |
dictionary name |
virtual std::vector<std::string> keys() const
Returns a vector of all the available keys in the dictionary.