68 const char*
const path,
91 if((token == NULL) || (*token == 0)) {
96 if((token[0] ==
'\'') || (token[0] ==
'"')) {
104 int index = strtol(token + offset, &endptr, 0);
145 src->
data.data = NULL;
151 dest->
data.data = NULL;
244 if(var_type == NULL) {
248 if((var_type != NULL) &&
249 (var_type->
del != NULL)) {
275 if(var_type->
init != NULL) {
299 retval = type->
copy(dest, src);
322 retval = type->
move(dest, src);
373 const uint32_t type_id) {
409 if((var1 == NULL) && (var2 == NULL)) {
414 if((var1 != NULL) && (var2 == NULL)) {
432 if((var1_type->
compare != NULL) &&
436 retval = var1_type->
compare(var1, &converted_var, result);
437 }
else if((var2_type->
compare != NULL) &&
441 retval = var2_type->
compare(&converted_var, var2, result);
450 const char*
const key,
461 retval = var_type->
get_key != NULL ?
469 const char*
const key,
482 retval = var_type->
set_key != NULL ?
539 retval = var_type->
set_key != NULL ?
574 const char*
const path,
601 const char*
const fmt,
624 const char*
const path,
646 const char*
const fmt,
822 const char* key = NULL;
#define when_failed(x, l)
Ambiorix string API header file.
int PRIVATE amxc_var_default_move(amxc_var_t *const dest, amxc_var_t *const src)
int PRIVATE amxc_var_default_convert_to_null(amxc_var_t *const dest, UNUSED const amxc_var_t *const src)
int PRIVATE amxc_var_default_convert_to_htable(amxc_var_t *const dest, const amxc_var_t *const src)
int amxc_var_set_pathf(amxc_var_t *const var, amxc_var_t *data, const int flags, const char *const fmt,...)
int PRIVATE amxc_var_default_copy(amxc_var_t *const dest, const amxc_var_t *const src)
int PRIVATE amxc_var_default_convert_to_list(amxc_var_t *const dest, const amxc_var_t *const src)
static amxc_var_t * amxc_var_find(amxc_var_t *const var, const char *const path, const int flags)
amxc_var_t * amxc_var_get_pathf(const amxc_var_t *const var, const int flags, const char *const fmt,...)
#define amxc_var_from_htable_it(ht_it)
Get the variant pointer from an amxc htable iterator.
#define amxc_var_from_llist_it(ll_it)
Get the variant pointer from an amxc linked list iterator.
Ambiorix ring buffer API header file.
#define amxc_container_of(addr, type, member)
Calculates the address of the containing structure.
amxc_htable_it_t * amxc_htable_it_get_next(const amxc_htable_it_t *const reference)
Gets the next iterator in the hash table.
int amxc_htable_it_init(amxc_htable_it_t *const it)
Initializes a hash table.iterator.
void amxc_htable_it_clean(amxc_htable_it_t *const it, amxc_htable_it_delete_t func)
Removes the iterator from the htable and frees allocated memory.
amxc_htable_it_t * amxc_htable_it_get_previous(const amxc_htable_it_t *const reference)
Gets the previous iterator in the hash table.
AMXC_INLINE const char * amxc_htable_it_get_key(const amxc_htable_it_t *const it)
Gets the key from the iterator.
amxc_htable_it_t * amxc_htable_get_first(const amxc_htable_t *const htable)
Gets the first item stored in the table.
amxc_htable_it_t * amxc_htable_get_last(const amxc_htable_t *const htable)
Gets the last item stored in the table.
int amxc_htable_insert(amxc_htable_t *const htable, const char *const key, amxc_htable_it_t *const it)
Inserts an item in the hash table.
void amxc_htable_clean(amxc_htable_t *const htable, amxc_htable_it_delete_t func)
Removes all items from the hash table.
int amxc_llist_it_init(amxc_llist_it_t *const it)
Initializes a linked list iterator.
AMXC_INLINE amxc_llist_it_t * amxc_llist_it_get_previous(const amxc_llist_it_t *const reference)
Gets the previous iterator in the list.
AMXC_INLINE amxc_llist_it_t * amxc_llist_it_get_next(const amxc_llist_it_t *const reference)
Gets the next iterator in the list.
void amxc_llist_it_clean(amxc_llist_it_t *const it, amxc_llist_it_delete_t func)
Removes the iterator from the list and frees allocated memory.
int amxc_llist_append(amxc_llist_t *const llist, amxc_llist_it_t *const it)
Adds an item to the end of the linked list.
int amxc_llist_init(amxc_llist_t *const llist)
Initializes a linked list.
void amxc_llist_clean(amxc_llist_t *const llist, amxc_llist_it_delete_t func)
Removes all items from the linked list.
#define amxc_llist_for_each(it, list)
Loops over the list from head to tail.
AMXC_INLINE amxc_llist_it_t * amxc_llist_get_last(const amxc_llist_t *const llist)
Gets the last item of the linked list.
AMXC_INLINE amxc_llist_it_t * amxc_llist_get_first(const amxc_llist_t *const llist)
Gets the first item of the linked list.
amxc_string_split_status_t amxc_string_split_to_llist(const amxc_string_t *const string, amxc_llist_t *list, const char separator)
Simple split function using a single character separator.
void amxc_string_list_it_free(amxc_llist_it_t *it)
Helper function to delete an item in a linked list.
void amxc_string_delete(amxc_string_t **string)
Frees the previously allocated string.
const char * amxc_string_get(const amxc_string_t *const string, const size_t offset)
Gets the content of the string buffer.
int amxc_string_push_buffer(amxc_string_t *const string, char *buffer, size_t length)
Sets the string buffer.
size_t amxc_string_set(amxc_string_t *const string, const char *text)
Sets a 0 terminated string in the string buffer.
int amxc_string_new(amxc_string_t **string, const size_t length)
Allocates a string.
AMXC_INLINE size_t amxc_string_text_length(const amxc_string_t *const string)
Gets the current size of the used string buffer.
int int amxc_string_vappendf(amxc_string_t *const string, const char *fmt, va_list ap)
Appends a formatted string to a string.
int amxc_string_init(amxc_string_t *const string, const size_t length)
Initializes a string.
void amxc_string_clean(amxc_string_t *const string)
Frees the string buffer and reset length attributes.
char * amxc_string_take_buffer(amxc_string_t *const string)
Takes the string buffer.
#define AMXC_VAR_FLAG_NO_INDEX
Only search by key and not by index. This flag can be used with amxc_var_get_path function.
#define AMXC_VAR_FLAG_DEFAULT
The default flag, do not copy, use variant as is.
#define AMXC_VAR_FLAG_COPY
Copy the variant, creates a new variant, leaves the source variant untouched.
#define AMXC_VAR_FLAG_AUTO_ADD
Add none existing variants to composite variants. This flag can be used with amxc_var_set_path and am...
amxc_string_t * amxc_var_take_amxc_string_t(amxc_var_t *const var)
Takes a value from a variant.
int amxc_var_push_amxc_string_t(amxc_var_t *const var, amxc_string_t *val)
Pushes a value in a variant.
int amxc_var_push_cstring_t(amxc_var_t *const var, char *val)
Pushes a value in a variant.
#define AMXC_VAR_ID_INVALID
Invalid variant type id.
#define AMXC_VAR_ID_NULL
Null variant type id (aka void)
#define AMXC_VAR_ID_CSTRING
C-string variant id (aka char *), null terminated string.
#define AMXC_VAR_ID_SSV_STRING
Space Separated Values string variant id.
#define AMXC_VAR_ID_ANY
Special variant id, typically used in cast or conversion functions.
#define AMXC_VAR_ID_CSV_STRING
Comma Separated Values string variant id.
#define AMXC_VAR_ID_LIST
Ambiorix Linked List variant id.
#define AMXC_VAR_ID_HTABLE
Ambiorix Hash Table variant id.
amxc_var_type_t * amxc_var_get_type(unsigned int type_id)
Get the type definition structure.
const char * amxc_var_get_type_name_from_id(const uint32_t type_id)
Get the type name.
int amxc_var_move(amxc_var_t *const dest, amxc_var_t *const src)
Moves the type and data from one variant (source) in another variant (destination).
uint32_t amxc_var_type_of(const amxc_var_t *const var)
Gets the variant type id of a variant.
amxc_var_t * amxc_var_get_last(const amxc_var_t *const var)
Gets the last variant in a htable or list variant.
int amxc_var_set_type(amxc_var_t *const var, const uint32_t type)
Change the variant data type.
amxc_var_t * amxc_var_get_path(const amxc_var_t *const var, const char *const path, const int flags)
Retrieves the variant at the given path of a composite variant.
int amxc_var_set_path(amxc_var_t *const var, const char *const path, amxc_var_t *data, const int flags)
Sets the variant at the given path of a composite variant.
amxc_var_t * amxc_var_get_key(const amxc_var_t *const var, const char *const key, const int flags)
Get a reference to a part of composed variant using a key.
const char * amxc_var_key(const amxc_var_t *const var)
Gets the key, with which the variant is stored in a htable variant.
int amxc_var_cast(amxc_var_t *const var, const uint32_t type_id)
Casts the variant to another variant type id.
int amxc_var_set_index(amxc_var_t *const var, const int64_t index, amxc_var_t *data, const int flags)
Set a part of composed variant using an index.
amxc_var_t * amxc_var_get_previous(const amxc_var_t *const var)
Gets the previous variant.
int amxc_var_new(amxc_var_t **var)
Allocates a variant and initializes it to the null variant type.
int amxc_var_init(amxc_var_t *const var)
Initializes a variant.
amxc_var_t * amxc_var_add_new(amxc_var_t *const var)
Adds a new variant to a composite variant.
int amxc_var_copy(amxc_var_t *const dest, const amxc_var_t *const src)
Copy the type and data from one variant (source) in another variant (destination).
void amxc_var_clean(amxc_var_t *const var)
Clean-up and reset variant.
void amxc_var_delete(amxc_var_t **var)
Frees the previously allocated variant.
int amxc_var_set_key(amxc_var_t *const var, const char *const key, amxc_var_t *data, const int flags)
Sets a part of composed variant using a key.
amxc_var_t * amxc_var_add_new_key(amxc_var_t *const var, const char *key)
Adds a new variant with a key to a composite variant.
amxc_var_t * amxc_var_get_parent(const amxc_var_t *const var)
Gets the containing variant.
amxc_var_t * amxc_var_get_index(const amxc_var_t *const var, const int64_t index, const int flags)
Get a reference to a part of composed variant using an index.
amxc_var_t * amxc_var_get_next(const amxc_var_t *const var)
Gets the next variant.
amxc_var_t * amxc_var_get_first(const amxc_var_t *const var)
Gets the first variant in a htable or list variant.
int amxc_var_convert(amxc_var_t *const dest, const amxc_var_t *const src, uint32_t type_id)
Converts one variant (source) to another variant(destination) using the specified variant type id.
int amxc_var_compare(const amxc_var_t *const var1, const amxc_var_t *const var2, int *result)
Compares two variants.
const char * amxc_var_type_name_of(const amxc_var_t *const var)
Gets the variant type name of a variant.
The hash table iterator structure.
The hash table structure.
The linked list iterator structure.
struct _amxc_llist * llist
The linked list structure.
A variant type structure.
amxc_var_get_key_fn_t get_key
amxc_var_get_index_fn_t get_index
amxc_var_compare_fn_t compare
amxc_var_set_key_fn_t set_key
amxc_var_convert_fn_t convert_from
amxc_var_convert_fn_t convert_to
amxc_var_set_index_fn_t set_index
The variant struct definition.
static amxc_htable_it_t it[2000]
static amxc_var_t * first