2 #include <ossia/detail/config.hpp>
4 #include <ossia/detail/any.hpp>
5 #include <ossia/detail/optional.hpp>
16 using extended_attributes =
any_map;
31 auto it = e.find(name);
34 auto val = ossia::any_cast<T>(&it->second);
57 auto it = e.find(name);
60 auto val = ossia::any_cast<T>(&it->second);
71 bool operator()(
const T&) noexcept
75 bool operator()(
const std::string& v) noexcept {
return v.empty(); }
76 bool operator()(
const std::string_view& v) noexcept {
return v.empty(); }
78 bool operator()(
const std::vector<T>& v) noexcept
92 if(!is_empty_value{}(val))
95 auto it = e.find(str);
99 e.insert(std::make_pair(std::string(str), ossia::any{val}));
116 template <
typename T>
119 if(!is_empty_value{}(val))
122 auto it = e.find(str);
124 it->second = std::move(val);
126 e.insert(std::make_pair(std::string(str), ossia::any{std::move(val)}));
139 template <
typename T>
141 any_map& e, std::string_view str,
const std::optional<T>& opt)
143 if(opt && !is_empty_value{}(*opt))
149 template <
typename T>
152 if(opt && !is_empty_value{}(*opt))
string_map< ossia::any > any_map
A container to store any kind of data indexed by a string.
Definition: any_map.hpp:14
auto get_attribute(const any_map &e, std::string_view name)
get_attribute Get an attribute of an any_map.
Definition: any_map.hpp:29
bool has_attribute(const any_map &e, std::string_view str) noexcept
Checks if an attribute is present.
Definition: any_map.cpp:6
std::optional< T > get_optional_attribute(const any_map &e, std::string_view name)
get_optional_attribute Maybe get an attribute of an any_map.
Definition: any_map.hpp:55
void set_optional_attribute(any_map &e, std::string_view str, const std::optional< T > &opt)
Sets an attribute if opt has a value, else remove the attribute.
Definition: any_map.hpp:140
void set_attribute(any_map &e, std::string_view str)
Sets a bool-like attribute. It should be checked for with has_attribute.
Definition: any_map.cpp:11
void unset_attribute(any_map &e, std::string_view str)
Remove an attribute.
Definition: any_map.cpp:23