Class meta_associative_container

Synopsis

#include <src/entt/meta/meta.hpp>

class meta_associative_container

Description

Proxy object for associative containers.

Mentioned in

Classes

meta_iteratorOpaque iterator for meta associative containers.

Methods

meta_associative_containerDefault constructor.
beginReturns a meta iterator to the first element of the wrapped container.
clearClears the content of the wrapped container.
endReturns a meta iterator that is past the last element of the wrapped container.
eraseRemoves the specified element from the wrapped container.
findReturns an iterator to the element with key equivalent to a given one, if any.
insertInserts an element (a key/value pair) into the wrapped container.
key_onlyReturns true if the associative container is also key-only, false otherwise.
key_typeReturns the key meta type of the wrapped container type.
mapped_typeReturns the mapped meta type of the wrapped container type.
operator boolReturns false if a proxy is invalid, true otherwise.
sizeReturns the size of the wrapped container.
value_typeReturns the value meta type of the wrapped container type.

Source

Lines 91-155 in src/entt/meta/meta.hpp.

class meta_associative_container {
    template<typename>
    struct meta_associative_container_proxy;

    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
        : instance{nullptr}
    {}

    /**
     * @brief Construct a proxy object for associative containers.
     * @tparam Type Type of container to wrap.
     * @param container The container to wrap.
     */
    template<typename Type>
    meta_associative_container(Type *container) ENTT_NOEXCEPT
        : key_only_container{is_key_only_meta_associative_container_v<Type>},
          key_type_fn{&meta_associative_container_proxy<Type>::key_type},
          mapped_type_fn{&meta_associative_container_proxy<Type>::mapped_type},
          value_type_fn{&meta_associative_container_proxy<Type>::value_type},
          size_fn{&meta_associative_container_proxy<Type>::size},
          clear_fn{&meta_associative_container_proxy<Type>::clear},
          begin_fn{&meta_associative_container_proxy<Type>::begin},
          end_fn{&meta_associative_container_proxy<Type>::end},
          insert_fn{&meta_associative_container_proxy<Type>::insert},
          erase_fn{&meta_associative_container_proxy<Type>::erase},
          find_fn{&meta_associative_container_proxy<Type>::find},
          instance{container}
    {}

    [[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;
    meta_type(* key_type_fn)() ENTT_NOEXCEPT;
    meta_type(* mapped_type_fn)() ENTT_NOEXCEPT;
    meta_type(* value_type_fn)() ENTT_NOEXCEPT;
    size_type(* size_fn)(const void *) ENTT_NOEXCEPT;
    bool(* clear_fn)(void *);
    iterator(* begin_fn)(void *);
    iterator(* end_fn)(void *);
    bool(* insert_fn)(void *, meta_any, meta_any);
    bool(* erase_fn)(void *, meta_any);
    iterator(* find_fn)(void *, meta_any);
    void *instance;
};





Add Discussion

Log in to comment