64 #include <amxc/amxc.h>
65 #include <amxp/amxp.h>
81 amxc_llist_it_t* part);
86 const char*
const path,
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;
134 size_t length = strlen(path);
135 when_true(length == 0, exit);
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] =
']';
213 amxc_llist_it_t* next) {
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);
237 amxc_llist_it_t* part) {
258 amxc_llist_it_t* part) {
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);
302 amxc_llist_it_t* part) {
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] ==
'*') {
320 amxc_llist_it_t* part) {
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]) {
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);
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);
#define when_failed_status(x, l, c)
Ambiorix Data Model API header file.
Ambiorix Data Model API header file.
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)
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_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_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_object_resolve_instances(amxd_object_t *const object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *part)
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_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_resolve_add_path_or_continue(amxd_object_t *object, bool *key_path, amxc_llist_t *paths, amxc_llist_it_t *next)
amxd_status_t amxd_object_resolve_internal(amxd_object_t *const object, bool *key_path, amxc_llist_t *paths, amxd_path_t *path)
static amxd_object_t * amxd_object_find(amxd_object_t *const object, bool *key_path, const char *path, amxd_status_t *status)
amxd_object_t * amxd_object_find_internal(amxd_object_t *const object, bool *key_path, amxd_path_t *path, amxd_status_t *status)
enum _amxd_status amxd_status_t
@ amxd_status_invalid_path
@ amxd_status_object_not_found
#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_object_t * amxd_object_get_parent(const amxd_object_t *const object)
Get the parent object.
amxd_object_t * amxd_object_get_child(const amxd_object_t *object, const char *name)
Get a child of the object.
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.
static amxd_object_type_t amxd_object_get_type(const amxd_object_t *const object)
Returns the object type.
#define amxd_object_for_each(type, it, object)
Helper macro for iterating object content.
static amxd_status_t status