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