#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <amxc/amxc.h>
#include <amxp/amxp.h>
#include <amxd/amxd_types.h>
#include <amxd/amxd_object.h>
#include <amxd/amxd_object_expression.h>
#include <amxd/amxd_dm.h>
#include <amxd/amxd_dm_functions.h>
#include "amxd_priv.h"
#include "amxd_dm_priv.h"
#include "amxd_object_priv.h"
#include "amxd_assert.h"
Go to the source code of this file.
|
static amxd_status_t | amxd_object_resolve_next (amxd_object_t *const object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *part) |
|
static amxd_object_t * | amxd_template_find (amxd_object_t *const object, bool *key_path, const char *const path, amxd_status_t *status) |
|
static amxd_object_t * | amxd_object_find (amxd_object_t *const object, bool *key_path, const char *path, amxd_status_t *status) |
|
static amxd_object_t * | amxd_template_find_instance (amxd_object_t *templ, bool *key_path, char *str_part, amxd_status_t *status) |
|
static amxd_status_t | amxd_resolve_add_path_or_continue (amxd_object_t *object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *next) |
|
static amxd_status_t | amxd_template_add_all_instances (amxd_object_t *object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *part) |
|
static amxd_status_t | amxd_template_add_matching_instances (amxd_object_t *object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *part) |
|
static amxd_status_t | amxd_object_resolve_instances (amxd_object_t *const object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *part) |
|
amxd_object_t * | amxd_object_find_internal (amxd_object_t *const object, bool *key_path, amxd_path_t *path, amxd_status_t *status) |
|
amxd_status_t | amxd_object_resolve_internal (amxd_object_t *const object, bool *key_path, amxc_llist_t *paths, amxd_path_t *path) |
|
◆ _GNU_SOURCE
◆ amxd_object_find()
Definition at line 128 of file amxd_object_search_priv.c.
134 size_t length = strlen(path);
135 when_true(length == 0, exit);
static amxd_object_t * amxd_template_find(amxd_object_t *const object, bool *key_path, const char *const path, amxd_status_t *status)
@ amxd_status_object_not_found
amxd_object_t * amxd_object_get_child(const amxd_object_t *object, const char *name)
Get a child of the object.
static amxd_status_t status
◆ amxd_object_find_internal()
Definition at line 364 of file amxd_object_search_priv.c.
369 char* str_part = NULL;
371 amxc_var_for_each(var, (&path->
parts)) {
372 str_part = amxc_var_take(cstring_t, var);
373 switch(str_part[0]) {
401 amxc_var_push(cstring_t, var, str_part);
403 when_null(result, exit);
static amxd_object_t * amxd_template_find_instance(amxd_object_t *templ, bool *key_path, char *str_part, amxd_status_t *status)
static amxd_object_t * amxd_object_find(amxd_object_t *const object, bool *key_path, const char *path, amxd_status_t *status)
@ amxd_status_invalid_path
amxd_object_t * amxd_object_get_parent(const amxd_object_t *const object)
Get the parent object.
static amxd_object_type_t amxd_object_get_type(const amxd_object_t *const object)
Returns the object type.
◆ amxd_object_resolve_instances()
static amxd_status_t amxd_object_resolve_instances |
( |
amxd_object_t *const |
object, |
|
|
bool * |
key_path, |
|
|
amxc_llist_t * |
paths, |
|
|
amxc_llist_it_t * |
part |
|
) |
| |
|
static |
Definition at line 299 of file amxd_object_search_priv.c.
304 amxc_var_t* var_part = amxc_var_from_llist_it(part);
305 const char* str_part = amxc_var_constcast(cstring_t, var_part);
307 if(str_part[0] ==
'*') {
static amxd_status_t amxd_template_add_all_instances(amxd_object_t *object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *part)
static amxd_status_t amxd_template_add_matching_instances(amxd_object_t *object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *part)
enum _amxd_status amxd_status_t
◆ amxd_object_resolve_internal()
Definition at line 410 of file amxd_object_search_priv.c.
415 amxc_llist_it_t* path_part_it = NULL;
416 const amxc_llist_t* lparts = NULL;
418 lparts = amxc_var_constcast(amxc_llist_t, &path->
parts);
419 path_part_it = amxc_llist_get_first(lparts);
420 if(path_part_it != NULL) {
425 when_failed(
status, exit);
429 amxc_llist_clean(paths, amxc_string_list_it_free);
static amxd_status_t amxd_object_resolve_next(amxd_object_t *const object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *part)
static amxd_status_t amxd_resolve_add_path_or_continue(amxd_object_t *object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *next)
◆ amxd_object_resolve_next()
static amxd_status_t amxd_object_resolve_next |
( |
amxd_object_t *const |
object, |
|
|
bool * |
key_path, |
|
|
amxc_llist_t * |
paths, |
|
|
amxc_llist_it_t * |
part |
|
) |
| |
|
static |
Definition at line 317 of file amxd_object_search_priv.c.
323 amxc_var_t* var_part = NULL;
324 const char* str_part = NULL;
326 var_part = amxc_var_from_llist_it(part);
327 str_part = amxc_var_constcast(cstring_t, var_part);
329 switch(str_part[0]) {
static amxd_status_t amxd_object_resolve_instances(amxd_object_t *const object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *part)
◆ amxd_resolve_add_path_or_continue()
static amxd_status_t amxd_resolve_add_path_or_continue |
( |
amxd_object_t * |
object, |
|
|
bool * |
key_path, |
|
|
amxc_llist_t * |
paths, |
|
|
amxc_llist_it_t * |
next |
|
) |
| |
|
static |
Definition at line 210 of file amxd_object_search_priv.c.
216 amxc_string_t* obj_path = NULL;
222 amxc_string_new(&obj_path, 0);
223 amxc_string_push_buffer(obj_path, path, strlen(path) + 1);
224 amxc_llist_append(paths, &obj_path->it);
#define AMXD_OBJECT_INDEXED
Name and path format flag - use index for instance objects.
#define AMXD_OBJECT_TERMINATE
Path format flag - when set the object path is terminated with a dot.
amxd_object_t amxd_status_t amxd_status_t char * amxd_object_get_path(const amxd_object_t *object, const uint32_t flags)
Get the full path of the object.
◆ amxd_template_add_all_instances()
static amxd_status_t amxd_template_add_all_instances |
( |
amxd_object_t * |
object, |
|
|
bool * |
key_path, |
|
|
amxc_llist_t * |
paths, |
|
|
amxc_llist_it_t * |
part |
|
) |
| |
|
static |
Definition at line 234 of file amxd_object_search_priv.c.
#define amxd_object_for_each(type, it, object)
Helper macro for iterating object content.
◆ amxd_template_add_matching_instances()
static amxd_status_t amxd_template_add_matching_instances |
( |
amxd_object_t * |
object, |
|
|
bool * |
key_path, |
|
|
amxc_llist_t * |
paths, |
|
|
amxc_llist_it_t * |
part |
|
) |
| |
|
static |
Definition at line 255 of file amxd_object_search_priv.c.
260 amxc_var_t* var_part = amxc_var_from_llist_it(part);
261 char* txt_part = amxc_var_dyncast(cstring_t, var_part);
264 int length = strlen(txt_part);
276 txt_part[length - 1] = 0;
277 if(amxp_expr_init(&expr, txt_part + 1) != 0) {
285 while(
object != NULL) {
291 amxp_expr_clean(&expr);
#define when_failed_status(x, l, c)
amxd_object_t * amxd_object_find_next_instance(const amxd_object_t *const instance, amxp_expr_t *expr)
amxd_object_t * amxd_object_find_instance(const amxd_object_t *const templ, amxp_expr_t *expr)
◆ amxd_template_find()
Definition at line 84 of file amxd_object_search_priv.c.
89 size_t length = strlen(path);
94 if(path[length - 1] ==
'.') {
102 when_true_status(length == 0,
106 index = strtoll(path + offset, &endptr, 0);
108 if((endptr != path) && ((*endptr ==
'.') || (*endptr ==
'\0') || (*endptr ==
']'))) {
111 char* copy_path = strdup(path + offset);
112 copy_path[length] = 0;
amxd_object_t * amxd_object_get_instance(const amxd_object_t *object, const char *name, uint32_t index)
Get an instance of the template object.
◆ amxd_template_find_instance()
Definition at line 152 of file amxd_object_search_priv.c.
162 length = strlen(str_part);
171 if(str_part[0] ==
'[') {
172 length = strlen(str_part);
174 str_part[length - 1] = 0;
177 if(amxp_expr_init(&expr, str_part + offset) != 0) {
184 if(expr.status != amxp_expr_status_ok) {
189 amxp_expr_clean(&expr);
199 amxp_expr_clean(&expr);
202 if(str_part[0] ==
'[') {
203 str_part[length - 1] =
']';