Class meta_associative_container
Synopsis
#include <src/entt/meta/meta.hpp>
class meta_associative_container
Description
Proxy object for associative containers.
Mentioned in
- Runtime Reflection System / Container support
Methods
meta_associative_container overload | Default constructor. | |
meta_associative_container overload | Construct a proxy object for associative containers. | |
begin | Returns an iterator to the first element of a container. | |
clear | Clears the content of a container. | |
end | Returns an iterator that is past the last element of a container. | |
erase | Removes the specified element from a container. | |
find | Returns an iterator to the element with a given key, if any. | |
insert | Inserts an element (a key/value pair) into a container. | |
key_only | Returns true if a container is also key-only, false otherwise. | |
key_type | Returns the meta key type of a container. | |
mapped_type | Returns the meta mapped type of a container. | |
operator bool | Returns false if a proxy is invalid, true otherwise. | |
size | Returns the size of a container. | |
value_type | Returns the meta value type of a container. |
Source
Lines 78-138 in src/entt/meta/meta.hpp.
class meta_associative_container {
class meta_iterator;
public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
/*! @brief Meta iterator type. */
using iterator = meta_iterator;
/*! @brief Default constructor. */
meta_associative_container() ENTT_NOEXCEPT = default;
/**
* @brief Construct a proxy object for associative containers.
* @tparam Type Type of container to wrap.
* @param instance The container to wrap.
*/
template<typename Type>
meta_associative_container(std::in_place_type_t<Type>, any instance) ENTT_NOEXCEPT
: key_only_container{meta_associative_container_traits<Type>::key_only},
key_type_node{internal::meta_node<std::remove_cv_t<std::remove_reference_t<typename Type::key_type>>>::resolve()},
mapped_type_node{nullptr},
value_type_node{internal::meta_node<std::remove_cv_t<std::remove_reference_t<typename Type::value_type>>>::resolve()},
size_fn{&meta_associative_container_traits<Type>::size},
clear_fn{&meta_associative_container_traits<Type>::clear},
iter_fn{&meta_associative_container_traits<Type>::iter},
insert_fn{&meta_associative_container_traits<Type>::insert},
erase_fn{&meta_associative_container_traits<Type>::erase},
find_fn{&meta_associative_container_traits<Type>::find},
storage{std::move(instance)} {
if constexpr(!meta_associative_container_traits<Type>::key_only) {
mapped_type_node = internal::meta_node<std::remove_cv_t<std::remove_reference_t<typename Type::mapped_type>>>::resolve();
}
}
[[nodiscard]] inline bool key_only() const ENTT_NOEXCEPT;
[[nodiscard]] inline meta_type key_type() const ENTT_NOEXCEPT;
[[nodiscard]] inline meta_type mapped_type() const ENTT_NOEXCEPT;
[[nodiscard]] inline meta_type value_type() const ENTT_NOEXCEPT;
[[nodiscard]] inline size_type size() const ENTT_NOEXCEPT;
inline bool clear();
[[nodiscard]] inline iterator begin();
[[nodiscard]] inline iterator end();
inline bool insert(meta_any, meta_any);
inline bool erase(meta_any);
[[nodiscard]] inline iterator find(meta_any);
[[nodiscard]] inline explicit operator bool() const ENTT_NOEXCEPT;
private:
bool key_only_container{};
internal::meta_type_node *key_type_node = nullptr;
internal::meta_type_node *mapped_type_node = nullptr;
internal::meta_type_node *value_type_node = nullptr;
size_type (*size_fn)(const any &) ENTT_NOEXCEPT = nullptr;
bool (*clear_fn)(any &) = nullptr;
iterator (*iter_fn)(any &, const bool) = nullptr;
bool (*insert_fn)(any &, meta_any &, meta_any &) = nullptr;
bool (*erase_fn)(any &, meta_any &) = nullptr;
iterator (*find_fn)(any &, meta_any &) = nullptr;
any storage{};
};