Flecs: include/flecs/addons/cpp/mixins/meta/cursor.hpp Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.0 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
cursor.hpp
1
5
6#pragma once
7
8namespace flecs {
9
17
22 struct cursor {
23 cursor(flecs::world_t *world, flecs::entity_t type_id, void *ptr) {
24 cursor_ = ecs_meta_cursor(world, type_id, ptr);
25 }
26
28 int push() {
29 return ecs_meta_push(&cursor_);
30 }
31
33 int pop() {
34 return ecs_meta_pop(&cursor_);
35 }
36
38 int next() {
39 return ecs_meta_next(&cursor_);
40 }
41
43 int member(const char *name) {
44 return ecs_meta_member(&cursor_, name);
45 }
46
48 int elem(int32_t elem) {
49 return ecs_meta_elem(&cursor_, elem);
50 }
51
53 bool is_collection() {
54 return ecs_meta_is_collection(&cursor_);
55 }
56
58 flecs::string_view get_member() const {
59 return flecs::string_view(ecs_meta_get_member(&cursor_));
60 }
61
63 flecs::entity get_type() const;
64
66 flecs::entity get_unit() const;
67
69 void* get_ptr() {
70 return ecs_meta_get_ptr(&cursor_);
71 }
72
74 int set_bool(bool value) {
75 return ecs_meta_set_bool(&cursor_, value);
76 }
77
79 int set_char(char value) {
80 return ecs_meta_set_char(&cursor_, value);
81 }
82
84 int set_int(int64_t value) {
85 return ecs_meta_set_int(&cursor_, value);
86 }
87
89 int set_uint(uint64_t value) {
90 return ecs_meta_set_uint(&cursor_, value);
91 }
92
94 int set_float(double value) {
95 return ecs_meta_set_float(&cursor_, value);
96 }
97
99 int set_string(const char *value) {
100 return ecs_meta_set_string(&cursor_, value);
101 }
102
104 int set_string_literal(const char *value) {
105 return ecs_meta_set_string_literal(&cursor_, value);
106 }
107
109 int set_entity(flecs::entity_t value) {
110 return ecs_meta_set_entity(&cursor_, value);
111 }
112
114 int set_id(flecs::id_t value) {
115 return ecs_meta_set_id(&cursor_, value);
116 }
117
119 int set_null() {
120 return ecs_meta_set_null(&cursor_);
121 }
122
124 bool get_bool() const {
125 return ecs_meta_get_bool(&cursor_);
126 }
127
129 char get_char() const {
130 return ecs_meta_get_char(&cursor_);
131 }
132
134 int64_t get_int() const {
135 return ecs_meta_get_int(&cursor_);
136 }
137
139 uint64_t get_uint() const {
140 return ecs_meta_get_uint(&cursor_);
141 }
142
144 double get_float() const {
145 return ecs_meta_get_float(&cursor_);
146 }
147
149 const char *get_string() const {
150 return ecs_meta_get_string(&cursor_);
151 }
152
154 flecs::entity get_entity() const;
155
157 ecs_meta_cursor_t cursor_;
158};
159
161
162}
ecs_meta_set_int
FLECS_API int ecs_meta_set_int(ecs_meta_cursor_t *cursor, int64_t value)
Set field with int value.
ecs_meta_next
FLECS_API int ecs_meta_next(ecs_meta_cursor_t *cursor)
Move cursor to next field.
ecs_meta_set_uint
FLECS_API int ecs_meta_set_uint(ecs_meta_cursor_t *cursor, uint64_t value)
Set field with uint value.
ecs_meta_get_bool
FLECS_API bool ecs_meta_get_bool(const ecs_meta_cursor_t *cursor)
Get field value as boolean.
ecs_meta_set_string_literal
FLECS_API int ecs_meta_set_string_literal(ecs_meta_cursor_t *cursor, const char *value)
Set field with string literal value (has enclosing "").
ecs_meta_set_float
FLECS_API int ecs_meta_set_float(ecs_meta_cursor_t *cursor, double value)
Set field with float value.
ecs_meta_is_collection
FLECS_API bool ecs_meta_is_collection(const ecs_meta_cursor_t *cursor)
Is the current scope a collection?
ecs_meta_set_id
FLECS_API int ecs_meta_set_id(ecs_meta_cursor_t *cursor, ecs_id_t value)
Set field with (component) id value.
ecs_meta_cursor
FLECS_API ecs_meta_cursor_t ecs_meta_cursor(const ecs_world_t *world, ecs_entity_t type, void *ptr)
Create meta cursor.
ecs_meta_get_string
FLECS_API const char * ecs_meta_get_string(const ecs_meta_cursor_t *cursor)
Get field value as string.
ecs_meta_get_member
FLECS_API const char * ecs_meta_get_member(const ecs_meta_cursor_t *cursor)
Get member name of current field.
ecs_meta_get_float
FLECS_API double ecs_meta_get_float(const ecs_meta_cursor_t *cursor)
Get field value as float.
ecs_meta_pop
FLECS_API int ecs_meta_pop(ecs_meta_cursor_t *cursor)
Pop a struct or collection scope (must follow a push).
ecs_meta_get_uint
FLECS_API uint64_t ecs_meta_get_uint(const ecs_meta_cursor_t *cursor)
Get field value as unsigned integer.
ecs_meta_get_char
FLECS_API char ecs_meta_get_char(const ecs_meta_cursor_t *cursor)
Get field value as char.
ecs_meta_elem
FLECS_API int ecs_meta_elem(ecs_meta_cursor_t *cursor, int32_t elem)
Move cursor to a field.
ecs_meta_get_int
FLECS_API int64_t ecs_meta_get_int(const ecs_meta_cursor_t *cursor)
Get field value as signed integer.
ecs_meta_set_string
FLECS_API int ecs_meta_set_string(ecs_meta_cursor_t *cursor, const char *value)
Set field with string value.
ecs_meta_member
FLECS_API int ecs_meta_member(ecs_meta_cursor_t *cursor, const char *name)
Move cursor to member.
ecs_meta_set_bool
FLECS_API int ecs_meta_set_bool(ecs_meta_cursor_t *cursor, bool value)
Set field with boolean value.
ecs_meta_set_char
FLECS_API int ecs_meta_set_char(ecs_meta_cursor_t *cursor, char value)
Set field with char value.
ecs_meta_get_ptr
FLECS_API void * ecs_meta_get_ptr(ecs_meta_cursor_t *cursor)
Get pointer to current field.
ecs_meta_set_null
FLECS_API int ecs_meta_set_null(ecs_meta_cursor_t *cursor)
Set field with null value.
ecs_meta_set_entity
FLECS_API int ecs_meta_set_entity(ecs_meta_cursor_t *cursor, ecs_entity_t value)
Set field with entity value.
ecs_meta_push
FLECS_API int ecs_meta_push(ecs_meta_cursor_t *cursor)
Push a scope (required/only valid for structs & collections).
ecs_meta_cursor_t
Type that enables iterating/populating a value using reflection data.
Definition meta.h:617
flecs::cursor::get_type
flecs::entity get_type() const
Get type of value.
flecs::cursor::set_bool
int set_bool(bool value)
Set boolean value.
Definition cursor.hpp:74
flecs::cursor::set_string_literal
int set_string_literal(const char *value)
Set string literal value.
Definition cursor.hpp:104
flecs::cursor::get_string
const char * get_string() const
Get string value.
Definition cursor.hpp:149
flecs::cursor::set_int
int set_int(int64_t value)
Set signed int value.
Definition cursor.hpp:84
flecs::cursor::member
int member(const char *name)
Move to member by name.
Definition cursor.hpp:43
flecs::cursor::get_uint
uint64_t get_uint() const
Get unsigned int value.
Definition cursor.hpp:139
flecs::cursor::get_char
char get_char() const
Get char value.
Definition cursor.hpp:129
flecs::cursor::elem
int elem(int32_t elem)
Move to element by index.
Definition cursor.hpp:48
flecs::cursor::get_bool
bool get_bool() const
Get boolean value.
Definition cursor.hpp:124
flecs::cursor::set_float
int set_float(double value)
Set float value.
Definition cursor.hpp:94
flecs::cursor::get_float
double get_float() const
Get float value.
Definition cursor.hpp:144
flecs::cursor::set_char
int set_char(char value)
Set char value.
Definition cursor.hpp:79
flecs::cursor::get_member
flecs::string_view get_member() const
Get member name.
Definition cursor.hpp:58
flecs::cursor::set_null
int set_null()
Set null value.
Definition cursor.hpp:119
flecs::cursor::is_collection
bool is_collection()
Test if current scope is a collection type.
Definition cursor.hpp:53
flecs::cursor::push
int push()
Push value scope (such as a nested struct)
Definition cursor.hpp:28
flecs::cursor::set_id
int set_id(flecs::id_t value)
Set (component) id value.
Definition cursor.hpp:114
flecs::cursor::set_uint
int set_uint(uint64_t value)
Set unsigned int value.
Definition cursor.hpp:89
flecs::cursor::set_string
int set_string(const char *value)
Set string value.
Definition cursor.hpp:99
flecs::cursor::pop
int pop()
Pop value scope.
Definition cursor.hpp:33
flecs::cursor::get_int
int64_t get_int() const
Get signed int value.
Definition cursor.hpp:134
flecs::cursor::get_entity
flecs::entity get_entity() const
Get entity value.
flecs::cursor::set_entity
int set_entity(flecs::entity_t value)
Set entity value.
Definition cursor.hpp:109
flecs::cursor::next
int next()
Move to next member/element.
Definition cursor.hpp:38
flecs::cursor::get_unit
flecs::entity get_unit() const
Get unit of value.
flecs::cursor::get_ptr
void * get_ptr()
Get untyped pointer to value.
Definition cursor.hpp:69
flecs::cursor::cursor_
ecs_meta_cursor_t cursor_
Cursor object.
Definition cursor.hpp:157
flecs::entity
Entity.
Definition entity.hpp:30
flecs::string_view
Definition string.hpp:146
flecs::world
The world.
Definition world.hpp:158