Struct meta_base

Synopsis

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

struct meta_base

Description

Opaque wrapper for meta base classes.

Mentioned in

Methods

meta_baseConstructs an instance from a given node.
castCasts an instance from a parent type to a base type.
operator boolReturns true if a meta object is valid, false otherwise.
parentReturns the meta type to which a meta object belongs.
typeReturns the meta type of the underlying object.

Source

Lines 619-656 in src/entt/meta/meta.hpp.

struct meta_base {
    /*! @brief Node type. */
    using node_type = internal::meta_base_node;

    /*! @copydoc meta_prop::meta_prop */
    meta_base(const node_type *curr = nullptr) ENTT_NOEXCEPT
        : node{curr}
    {}

    /**
     * @brief Returns the meta type to which a meta object belongs.
     * @return The meta type to which the meta object belongs.
     */
    [[nodiscard]] inline meta_type parent() const ENTT_NOEXCEPT;

    /*! @copydoc meta_any::type */
    [[nodiscard]] inline meta_type type() const ENTT_NOEXCEPT;

    /**
     * @brief Casts an instance from a parent type to a base type.
     * @param instance The instance to cast.
     * @return An opaque pointer to the base type.
     */
    [[nodiscard]] const void * cast(const void *instance) const ENTT_NOEXCEPT {
        return node->cast(instance);
    }

    /**
     * @brief Returns true if a meta object is valid, false otherwise.
     * @return True if the meta object is valid, false otherwise.
     */
    [[nodiscard]] explicit operator bool() const ENTT_NOEXCEPT {
        return !(node == nullptr);
    }

private:
    const node_type *node;
};





Add Discussion

Log in to comment