A file that contains the KVar system. KVars are global variables that are dynamically created and set/used within the engine and/or application, and are accessible from anywhere.
More...
Go to the source code of this file.
|
b8 | kvar_system_initialize (u64 *memory_requirement, struct kvar_state *memory, void *config) |
| Initializes the KVar system. KVars are global variables that are dynamically created and set/used within the engine and/or application, and are accessible from anywhere. Like any other system, this should be called twice, once to obtain the memory requirement (where memory = 0), and a second time with an allocated block of memory. More...
|
|
void | kvar_system_shutdown (struct kvar_state *state) |
| Shuts down the KVar system. More...
|
|
KAPI b8 | kvar_i32_get (const char *name, i32 *out_value) |
| Attempts to obtain a variable value with the given name and return its value as an integer. Also attempts conversion if the variable is a type other than int, but this conversion can fail. More...
|
|
KAPI b8 | kvar_i32_set (const char *name, const char *desc, i32 value) |
| Attempts to set the value as an integer of an existing variable with the given name. Creates if the variable does not yet exist. More...
|
|
KAPI b8 | kvar_f32_get (const char *name, f32 *out_value) |
| Attempts to obtain a variable value with the given name and return its value as a float. Also attempts conversion if the variable is a type other than float, but this conversion can fail. More...
|
|
KAPI b8 | kvar_f32_set (const char *name, const char *desc, f32 value) |
| Attempts to set the value as a float of an existing variable with the given name. Creates if the variable does not yet exist. More...
|
|
KAPI const char * | kvar_string_get (const char *name) |
| Attempts to obtain a variable value with the given name and return its value as a string. Also attempts conversion if the variable is a type other than string, but this conversion can fail. Return value is dynamically allocated and must be freed by the caller. More...
|
|
KAPI b8 | kvar_string_set (const char *name, const char *desc, const char *value) |
| Attempts to set the value as a string of an existing variable with the given name. Creates if the variable does not yet exist. More...
|
|
A file that contains the KVar system. KVars are global variables that are dynamically created and set/used within the engine and/or application, and are accessible from anywhere.
- Author
- Travis Vroman (travi.nosp@m.s@ko.nosp@m.hieng.nosp@m.ine..nosp@m.com)
- Version
- 2.0
- Date
- 2024-04-2
- Copyright
- Kohi Game Engine is Copyright (c) Travis Vroman 2021-2024
◆ kvar_change
◆ kvar_types
◆ kvar_value
◆ kvar_types
Enumerator |
---|
KVAR_TYPE_INT | |
KVAR_TYPE_FLOAT | |
KVAR_TYPE_STRING | |
◆ kvar_f32_get()
KAPI b8 kvar_f32_get |
( |
const char * |
name, |
|
|
f32 * |
out_value |
|
) |
| |
Attempts to obtain a variable value with the given name and return its value as a float. Also attempts conversion if the variable is a type other than float, but this conversion can fail.
- Parameters
-
name | The name of the variable. |
out_value | A pointer to hold the variable. |
- Returns
- True if the variable was found and the value was successfully converted/returned; otherwise false.
◆ kvar_f32_set()
KAPI b8 kvar_f32_set |
( |
const char * |
name, |
|
|
const char * |
desc, |
|
|
f32 |
value |
|
) |
| |
Attempts to set the value as a float of an existing variable with the given name. Creates if the variable does not yet exist.
- Parameters
-
name | The name of the variable. |
description | Description of the variable. Optional. If updating existing, description will be overwritten unless 0 is passed. |
value | The value to be set. |
- Returns
- True if found and set, otherwise false.
◆ kvar_i32_get()
KAPI b8 kvar_i32_get |
( |
const char * |
name, |
|
|
i32 * |
out_value |
|
) |
| |
Attempts to obtain a variable value with the given name and return its value as an integer. Also attempts conversion if the variable is a type other than int, but this conversion can fail.
- Parameters
-
name | The name of the variable. |
out_value | A pointer to hold the variable. |
- Returns
- True if the variable was found and the value was successfully converted/returned; otherwise false.
◆ kvar_i32_set()
KAPI b8 kvar_i32_set |
( |
const char * |
name, |
|
|
const char * |
desc, |
|
|
i32 |
value |
|
) |
| |
Attempts to set the value as an integer of an existing variable with the given name. Creates if the variable does not yet exist.
- Parameters
-
name | The name of the variable. |
description | Description of the variable. Optional. If updating existing, description will be overwritten unless 0 is passed. |
value | The value to be set. |
- Returns
- True if found and set, otherwise false.
◆ kvar_string_get()
KAPI const char* kvar_string_get |
( |
const char * |
name | ) |
|
Attempts to obtain a variable value with the given name and return its value as a string. Also attempts conversion if the variable is a type other than string, but this conversion can fail. Return value is dynamically allocated and must be freed by the caller.
- Parameters
-
name | The name of the variable. |
- Returns
- A copy of the value as a string, or 0 if the operation fails. Must be freed by the caller.
◆ kvar_string_set()
KAPI b8 kvar_string_set |
( |
const char * |
name, |
|
|
const char * |
desc, |
|
|
const char * |
value |
|
) |
| |
Attempts to set the value as a string of an existing variable with the given name. Creates if the variable does not yet exist.
- Parameters
-
name | The name of the variable. |
description | Description of the variable. Optional. If updating existing, description will be overwritten unless 0 is passed. |
value | The value to be set. |
- Returns
- True if found and set, otherwise false.
◆ kvar_system_initialize()
b8 kvar_system_initialize |
( |
u64 * |
memory_requirement, |
|
|
struct kvar_state * |
memory, |
|
|
void * |
config |
|
) |
| |
Initializes the KVar system. KVars are global variables that are dynamically created and set/used within the engine and/or application, and are accessible from anywhere. Like any other system, this should be called twice, once to obtain the memory requirement (where memory = 0), and a second time with an allocated block of memory.
- Parameters
-
memory_requirement | A pointer to hold the memory requirement for this system. |
memory | An allocated block of memory the size of memory_requirement. |
config | A pointer to config, if required. |
- Returns
- b8 True on success; otherwise false.
◆ kvar_system_shutdown()
void kvar_system_shutdown |
( |
struct kvar_state * |
state | ) |
|
Shuts down the KVar system.
- Parameters
-