Struct rule_base

Synopsis

#include <include/flecs/addons/cpp/mixins/rule/impl.hpp>

struct rule_base

Description

No description yet.

Methods

rule_base overload
destructFree the rule.
operator rule
operator rule_t *
str

Source

Lines 11-57 in include/flecs/addons/cpp/mixins/rule/impl.hpp.

struct rule_base {
    rule_base()
        : m_world(nullptr)
        , m_rule(nullptr) { }

    rule_base(world_t *world, rule_t *rule = nullptr)
        : m_world(world)
        , m_rule(rule) { }

    rule_base(world_t *world, ecs_filter_desc_t *desc) 
        : m_world(world)
    {
        m_rule = ecs_rule_init(world, desc);

        if (!m_rule) {
            ecs_abort(ECS_INVALID_PARAMETER, NULL);
        }

        if (desc->terms_buffer) {
            ecs_os_free(desc->terms_buffer);
        }
    }

    operator rule_t*() const {
        return m_rule;
    }

    /** Free the rule.
     */
    void destruct() {
        ecs_rule_fini(m_rule);
        m_world = nullptr;
        m_rule = nullptr;
    }

    flecs::string str() {
        const ecs_filter_t *f = ecs_rule_get_filter(m_rule);
        char *result = ecs_filter_str(m_world, f);
        return flecs::string(result);
    }

    operator rule<>() const;

protected:
    world_t *m_world;
    rule_t *m_rule;
};