libamxc  1.10.3
C Generic Data Containers
variant type helper functions

Variant type specific helper functions. More...

Collaboration diagram for variant type helper functions:

Functions

void variant_list_it_free (amxc_llist_it_t *it)
 Helper functions, can be used as delete function for linked lists. More...
 
void variant_htable_it_free (const char *key, amxc_htable_it_t *it)
 Helper functions, can be used as delete function for htable. More...
 
int amxc_var_set_bool (amxc_var_t *const var, bool boolean)
 Setter helper function. More...
 
int amxc_var_set_int8_t (amxc_var_t *const var, int8_t val)
 Setter helper function. More...
 
int amxc_var_set_uint8_t (amxc_var_t *const var, uint8_t val)
 Setter helper function. More...
 
int amxc_var_set_int16_t (amxc_var_t *const var, int16_t val)
 Setter helper function. More...
 
int amxc_var_set_uint16_t (amxc_var_t *const var, uint16_t val)
 Setter helper function. More...
 
int amxc_var_set_int32_t (amxc_var_t *const var, int32_t val)
 Setter helper function. More...
 
int amxc_var_set_uint32_t (amxc_var_t *const var, uint32_t val)
 Setter helper function. More...
 
int amxc_var_set_int64_t (amxc_var_t *const var, int64_t val)
 Setter helper function. More...
 
int amxc_var_set_uint64_t (amxc_var_t *const var, uint64_t val)
 Setter helper function. More...
 
int amxc_var_set_cstring_t (amxc_var_t *const var, const char *const val)
 Setter helper function. More...
 
int amxc_var_set_csv_string_t (amxc_var_t *const var, const char *const val)
 Setter helper function. More...
 
int amxc_var_set_ssv_string_t (amxc_var_t *const var, const char *const val)
 Setter helper function. More...
 
int amxc_var_set_double (amxc_var_t *var, double val)
 Setter helper function. More...
 
int amxc_var_set_fd_t (amxc_var_t *var, int val)
 Setter helper function. More...
 
int amxc_var_set_amxc_ts_t (amxc_var_t *var, amxc_ts_t *val)
 Setter helper function. More...
 
bool amxc_var_get_bool (const amxc_var_t *const var)
 Conversion helper function. More...
 
int8_t amxc_var_get_int8_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
uint8_t amxc_var_get_uint8_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
int16_t amxc_var_get_int16_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
uint16_t amxc_var_get_uint16_t (const amxc_var_t *var)
 Conversion helper function. More...
 
int32_t amxc_var_get_int32_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
uint32_t amxc_var_get_uint32_t (const amxc_var_t *var)
 Conversion helper function. More...
 
int64_t amxc_var_get_int64_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
uint64_t amxc_var_get_uint64_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
char * amxc_var_get_cstring_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
amxc_htable_tamxc_var_get_amxc_htable_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
amxc_llist_tamxc_var_get_amxc_llist_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
double amxc_var_get_double (const amxc_var_t *var)
 Conversion helper function. More...
 
int amxc_var_get_fd_t (const amxc_var_t *var)
 Conversion helper function. More...
 
amxc_ts_tamxc_var_get_amxc_ts_t (const amxc_var_t *var)
 Conversion helper function. More...
 
AMXC_INLINE char * amxc_var_get_csv_string_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
AMXC_INLINE char * amxc_var_get_ssv_string_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
const char * amxc_var_get_const_cstring_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
const amxc_htable_tamxc_var_get_const_amxc_htable_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
const amxc_llist_tamxc_var_get_const_amxc_llist_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
bool amxc_var_get_const_bool (const amxc_var_t *const var)
 Conversion helper function. More...
 
int8_t amxc_var_get_const_int8_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
int16_t amxc_var_get_const_int16_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
int32_t amxc_var_get_const_int32_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
int64_t amxc_var_get_const_int64_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
uint8_t amxc_var_get_const_uint8_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
uint16_t amxc_var_get_const_uint16_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
uint32_t amxc_var_get_const_uint32_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
uint64_t amxc_var_get_const_uint64_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
double amxc_var_get_const_double (const amxc_var_t *const var)
 Conversion helper function. More...
 
int amxc_var_get_const_fd_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
const amxc_ts_tamxc_var_get_const_amxc_ts_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
AMXC_INLINE const char * amxc_var_get_const_csv_string_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
AMXC_INLINE const char * amxc_var_get_const_ssv_string_t (const amxc_var_t *const var)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_bool (amxc_var_t *const var, bool boolean)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_int8_t (amxc_var_t *const var, int8_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_uint8_t (amxc_var_t *const var, uint8_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_int16_t (amxc_var_t *const var, int16_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_uint16_t (amxc_var_t *const var, uint16_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_int32_t (amxc_var_t *const var, int32_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_uint32_t (amxc_var_t *const var, uint32_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_int64_t (amxc_var_t *const var, int64_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_uint64_t (amxc_var_t *const var, uint64_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_cstring_t (amxc_var_t *const var, const char *const val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_csv_string_t (amxc_var_t *const var, const char *const val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_ssv_string_t (amxc_var_t *const var, const char *const val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_double (amxc_var_t *const var, double val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_fd_t (amxc_var_t *const var, int val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_amxc_ts_t (amxc_var_t *const var, amxc_ts_t *ts)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_amxc_llist_t (amxc_var_t *const var, const amxc_llist_t *list)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_amxc_htable_t (amxc_var_t *const var, const amxc_htable_t *htable)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_bool (amxc_var_t *const var, const char *key, bool boolean)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_int8_t (amxc_var_t *const var, const char *key, int8_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_uint8_t (amxc_var_t *const var, const char *key, uint8_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_int16_t (amxc_var_t *const var, const char *key, int16_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_uint16_t (amxc_var_t *const var, const char *key, uint16_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_int32_t (amxc_var_t *const var, const char *key, int32_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_uint32_t (amxc_var_t *const var, const char *key, uint32_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_int64_t (amxc_var_t *const var, const char *key, int64_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_uint64_t (amxc_var_t *const var, const char *key, uint64_t val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_cstring_t (amxc_var_t *const var, const char *key, const char *const val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_csv_string_t (amxc_var_t *const var, const char *key, const char *const val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_ssv_string_t (amxc_var_t *const var, const char *key, const char *const val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_double (amxc_var_t *const var, const char *key, double val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_fd_t (amxc_var_t *const var, const char *key, int val)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_amxc_ts_t (amxc_var_t *const var, const char *key, amxc_ts_t *ts)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_amxc_llist_t (amxc_var_t *const var, const char *key, const amxc_llist_t *list)
 Conversion helper function. More...
 
amxc_var_tamxc_var_add_new_key_amxc_htable_t (amxc_var_t *const var, const char *key, const amxc_htable_t *htable)
 Conversion helper function. More...
 
char * amxc_var_take_cstring_t (amxc_var_t *const var)
 Takes a value from a variant. More...
 
amxc_string_tamxc_var_take_amxc_string_t (amxc_var_t *const var)
 Takes a value from a variant. More...
 
AMXC_INLINE char * amxc_var_take_csv_string_t (amxc_var_t *const var)
 Takes a value from a variant. More...
 
AMXC_INLINE char * amxc_var_take_ssv_string_t (amxc_var_t *const var)
 Takes a value from a variant. More...
 
int amxc_var_push_cstring_t (amxc_var_t *const var, char *val)
 Pushes a value in a variant. More...
 
int amxc_var_push_csv_string_t (amxc_var_t *const var, char *val)
 Pushes a value in a variant. More...
 
int amxc_var_push_ssv_string_t (amxc_var_t *const var, char *val)
 Pushes a value in a variant. More...
 
int amxc_var_push_amxc_string_t (amxc_var_t *const var, amxc_string_t *val)
 Pushes a value in a variant. More...
 

Detailed Description

Variant type specific helper functions.

These functions are normally not used directly. Either they are called using a macro or used as a callback function.

Function Documentation

◆ amxc_var_add_new_amxc_htable_t()

amxc_var_t* amxc_var_add_new_amxc_htable_t ( amxc_var_t *const  var,
const amxc_htable_t htable 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

If the provided htable pointer is NULL, an empty htable is added.

Note
Do not call this function directly, use macro amxc_var_add with the type argument amxc_htable_t
The htable must be a htable where the values are variants
Parameters
varpointer to a variant struct
htablethe new htable value
Returns
The new variant

Definition at line 455 of file variant_htable.c.

456  {
457  amxc_var_t* subvar = NULL;
458 
459  when_null(var, exit);
460  subvar = amxc_var_add_new(var);
461  when_null(subvar, exit);
462 
464  when_null(htable, exit);
465 
466  if(variant_htable_copy_htable(subvar, htable) != 0) {
467  amxc_var_delete(&subvar);
468  }
469 
470 exit:
471  return subvar;
472 }
#define when_null(x, l)
Definition: amxc_macros.h:126
#define AMXC_VAR_ID_HTABLE
Ambiorix Hash Table variant id.
Definition: amxc_variant.h:212
int amxc_var_set_type(amxc_var_t *const var, const uint32_t type)
Change the variant data type.
Definition: amxc_variant.c:261
amxc_var_t * amxc_var_add_new(amxc_var_t *const var)
Adds a new variant to a composite variant.
Definition: amxc_variant.c:551
void amxc_var_delete(amxc_var_t **var)
Frees the previously allocated variant.
Definition: amxc_variant.c:207
The variant struct definition.
Definition: amxc_variant.h:861
static amxc_htable_t * htable
static amxc_var_t * var
Definition: test_issue_58.c:77
static int variant_htable_copy_htable(amxc_var_t *const dest, const amxc_htable_t *const src_htable)

◆ amxc_var_add_new_amxc_llist_t()

amxc_var_t* amxc_var_add_new_amxc_llist_t ( amxc_var_t *const  var,
const amxc_llist_t list 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

If the provided list pointer is NULL, an empty list is added.

Note
Do not call this function directly, use macro amxc_var_add with the type argument amxc_llist_t
The list must be a list of variants
Parameters
varpointer to a variant struct
listthe new list value
Returns
The new variant

Definition at line 422 of file variant_list.c.

423  {
424  amxc_var_t* subvar = NULL;
425 
426  when_null(var, exit);
427  subvar = amxc_var_add_new(var);
428  when_null(subvar, exit);
429 
431  when_null(list, exit);
432 
433  if(variant_list_copy_list(subvar, list) != 0) {
434  amxc_var_delete(&subvar);
435  }
436 
437 exit:
438  return subvar;
439 }
#define AMXC_VAR_ID_LIST
Ambiorix Linked List variant id.
Definition: amxc_variant.h:206
static int variant_list_copy_list(amxc_var_t *const dest, const amxc_llist_t *source_list)
Definition: variant_list.c:75

◆ amxc_var_add_new_amxc_ts_t()

amxc_var_t* amxc_var_add_new_amxc_ts_t ( amxc_var_t *const  var,
amxc_ts_t ts 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument amxc_ts_t
Parameters
varpointer to a variant struct
tsthe timestamp value
Returns
The new variant

Definition at line 213 of file variant_timestamp.c.

213  {
214  amxc_var_t* subvar = NULL;
215 
216  when_null(var, exit);
217  subvar = amxc_var_add_new(var);
218  when_null(subvar, exit);
219 
220  if(ts == NULL) {
222  } else {
223  if(amxc_var_set_amxc_ts_t(subvar, ts) != 0) {
224  amxc_var_delete(&subvar);
225  }
226  }
227 
228 exit:
229  return subvar;
230 }
int amxc_var_set_amxc_ts_t(amxc_var_t *var, amxc_ts_t *ts)
Setter helper function.
#define AMXC_VAR_ID_TIMESTAMP
Ambiorix timestamp variant id.
Definition: amxc_variant.h:224

◆ amxc_var_add_new_bool()

amxc_var_t* amxc_var_add_new_bool ( amxc_var_t *const  var,
bool  boolean 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument bool
Parameters
varpointer to a variant struct
booleanthe value
Returns
The new variant

Definition at line 259 of file variant_bool.c.

259  {
260  amxc_var_t* subvar = NULL;
261 
262  when_null(var, exit);
263  subvar = amxc_var_add_new(var);
264  when_null(subvar, exit);
265 
266  if(amxc_var_set_bool(subvar, boolean) != 0) {
267  amxc_var_delete(&subvar);
268  }
269 
270 exit:
271  return subvar;
272 }
int amxc_var_set_bool(amxc_var_t *var, bool boolean)
Setter helper function.
Definition: variant_bool.c:221

◆ amxc_var_add_new_cstring_t()

amxc_var_t* amxc_var_add_new_cstring_t ( amxc_var_t *const  var,
const char *const  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument cstring_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 666 of file variant_char.c.

666  {
667  amxc_var_t* subvar = NULL;
668 
669  when_null(var, exit);
670  subvar = amxc_var_add_new(var);
671  when_null(subvar, exit);
672 
673  if(amxc_var_set_cstring_t(subvar, val) != 0) {
674  amxc_var_delete(&subvar);
675  }
676 
677 exit:
678  return subvar;
679 }
int amxc_var_set_cstring_t(amxc_var_t *const var, const char *const val)
Setter helper function.
Definition: variant_char.c:549

◆ amxc_var_add_new_csv_string_t()

amxc_var_t* amxc_var_add_new_csv_string_t ( amxc_var_t *const  var,
const char *const  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument csv_string_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 681 of file variant_char.c.

681  {
682  amxc_var_t* subvar = NULL;
683 
684  when_null(var, exit);
685  subvar = amxc_var_add_new(var);
686  when_null(subvar, exit);
687 
688  if(amxc_var_set_csv_string_t(subvar, val) != 0) {
689  amxc_var_delete(&subvar);
690  }
691 
692 exit:
693  return subvar;
694 }
int amxc_var_set_csv_string_t(amxc_var_t *const var, const char *const val)
Setter helper function.
Definition: variant_char.c:561

◆ amxc_var_add_new_double()

amxc_var_t* amxc_var_add_new_double ( amxc_var_t *const  var,
double  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument double
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 339 of file variant_double.c.

339  {
340  amxc_var_t* subvar = NULL;
341 
342  when_null(var, exit);
343  subvar = amxc_var_add_new(var);
344  when_null(subvar, exit);
345 
346  if(amxc_var_set_double(subvar, val) != 0) {
347  amxc_var_delete(&subvar);
348  }
349 
350 exit:
351  return subvar;
352 }
int amxc_var_set_double(amxc_var_t *var, double val)
Setter helper function.

◆ amxc_var_add_new_fd_t()

amxc_var_t* amxc_var_add_new_fd_t ( amxc_var_t *const  var,
int  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument fd_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 328 of file variant_fd.c.

328  {
329  amxc_var_t* subvar = NULL;
330 
331  when_null(var, exit);
332  subvar = amxc_var_add_new(var);
333  when_null(subvar, exit);
334 
335  if(amxc_var_set_fd_t(subvar, val) != 0) {
336  amxc_var_delete(&subvar);
337  }
338 
339 exit:
340  return subvar;
341 }
int amxc_var_set_fd_t(amxc_var_t *var, int val)
Setter helper function.
Definition: variant_fd.c:285

◆ amxc_var_add_new_int16_t()

amxc_var_t* amxc_var_add_new_int16_t ( amxc_var_t *const  var,
int16_t  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument int16_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 329 of file variant_int16.c.

329  {
330  amxc_var_t* subvar = NULL;
331 
332  when_null(var, exit);
333  subvar = amxc_var_add_new(var);
334  when_null(subvar, exit);
335 
336  if(amxc_var_set_int16_t(subvar, val) != 0) {
337  amxc_var_delete(&subvar);
338  }
339 
340 exit:
341  return subvar;
342 }
int amxc_var_set_int16_t(amxc_var_t *var, int16_t val)
Setter helper function.

◆ amxc_var_add_new_int32_t()

amxc_var_t* amxc_var_add_new_int32_t ( amxc_var_t *const  var,
int32_t  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument int32_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 334 of file variant_int32.c.

334  {
335  amxc_var_t* subvar = NULL;
336 
337  when_null(var, exit);
338  subvar = amxc_var_add_new(var);
339  when_null(subvar, exit);
340 
341  if(amxc_var_set_int32_t(subvar, val) != 0) {
342  amxc_var_delete(&subvar);
343  }
344 
345 exit:
346  return subvar;
347 }
int amxc_var_set_int32_t(amxc_var_t *var, int32_t val)
Setter helper function.

◆ amxc_var_add_new_int64_t()

amxc_var_t* amxc_var_add_new_int64_t ( amxc_var_t *const  var,
int64_t  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument int64_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 341 of file variant_int64.c.

341  {
342  amxc_var_t* subvar = NULL;
343 
344  when_null(var, exit);
345  subvar = amxc_var_add_new(var);
346  when_null(subvar, exit);
347 
348  if(amxc_var_set_int64_t(subvar, val) != 0) {
349  amxc_var_delete(&subvar);
350  }
351 
352 exit:
353  return subvar;
354 }
int amxc_var_set_int64_t(amxc_var_t *var, int64_t val)
Setter helper function.

◆ amxc_var_add_new_int8_t()

amxc_var_t* amxc_var_add_new_int8_t ( amxc_var_t *const  var,
int8_t  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument int8_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 316 of file variant_int8.c.

316  {
317  amxc_var_t* subvar = NULL;
318 
319  when_null(var, exit);
320  subvar = amxc_var_add_new(var);
321  when_null(subvar, exit);
322 
323  if(amxc_var_set_int8_t(subvar, val) != 0) {
324  amxc_var_delete(&subvar);
325  }
326 
327 exit:
328  return subvar;
329 }
int amxc_var_set_int8_t(amxc_var_t *var, int8_t val)
Setter helper function.
Definition: variant_int8.c:278

◆ amxc_var_add_new_key_amxc_htable_t()

amxc_var_t* amxc_var_add_new_key_amxc_htable_t ( amxc_var_t *const  var,
const char *  key,
const amxc_htable_t htable 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

If the provided htable pointer is NULL, an empty htable is added.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument amxc_htable_t
The linked list must be a list where the values are variants
Parameters
varpointer to a variant struct
keythe key
htablethe new htable value
Returns
The new variant

Definition at line 474 of file variant_htable.c.

476  {
477  amxc_var_t* subvar = NULL;
478 
479  when_null(var, exit);
480  subvar = amxc_var_add_new_key(var, key);
481  when_null(subvar, exit);
482 
484  when_null(htable, exit);
485 
486  if(variant_htable_copy_htable(subvar, htable) != 0) {
487  amxc_var_delete(&subvar);
488  }
489 
490 exit:
491  return subvar;
492 }
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.
Definition: amxc_variant.c:526

◆ amxc_var_add_new_key_amxc_llist_t()

amxc_var_t* amxc_var_add_new_key_amxc_llist_t ( amxc_var_t *const  var,
const char *  key,
const amxc_llist_t list 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

If the provided list pointer is NULL, an empty list is added.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument amxc_llist_t
The linked list must be a list where the values are variants
Parameters
varpointer to a variant struct
keythe key
listthe new list value
Returns
The new variant

Definition at line 441 of file variant_list.c.

443  {
444  amxc_var_t* subvar = NULL;
445 
446  when_null(var, exit);
447  subvar = amxc_var_add_new_key(var, key);
448  when_null(subvar, exit);
449 
451  when_null(list, exit);
452 
453  if(variant_list_copy_list(subvar, list) != 0) {
454  amxc_var_delete(&subvar);
455  }
456 
457 exit:
458  return subvar;
459 }

◆ amxc_var_add_new_key_amxc_ts_t()

amxc_var_t* amxc_var_add_new_key_amxc_ts_t ( amxc_var_t *const  var,
const char *  key,
amxc_ts_t ts 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument ts_t
Parameters
varpointer to a variant struct
keythe key
tsthe timestamp value
Returns
The new variant

Definition at line 232 of file variant_timestamp.c.

234  {
235  amxc_var_t* subvar = NULL;
236 
237  when_null(var, exit);
238  subvar = amxc_var_add_new_key(var, key);
239  when_null(subvar, exit);
240 
241  if(ts == NULL) {
243  } else {
244  if(amxc_var_set_amxc_ts_t(subvar, ts) != 0) {
245  amxc_var_delete(&subvar);
246  }
247  }
248 
249 exit:
250  return subvar;
251 }

◆ amxc_var_add_new_key_bool()

amxc_var_t* amxc_var_add_new_key_bool ( amxc_var_t *const  var,
const char *  key,
bool  boolean 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument bool
Parameters
varpointer to a variant struct
keythe key
booleanthe new boolean value
Returns
The new variant

Definition at line 274 of file variant_bool.c.

274  {
275  amxc_var_t* subvar = NULL;
276 
277  when_null(var, exit);
278  subvar = amxc_var_add_new_key(var, key);
279  when_null(subvar, exit);
280 
281  if(amxc_var_set_bool(subvar, boolean) != 0) {
282  amxc_var_delete(&subvar);
283  }
284 
285 exit:
286  return subvar;
287 }

◆ amxc_var_add_new_key_cstring_t()

amxc_var_t* amxc_var_add_new_key_cstring_t ( amxc_var_t *const  var,
const char *  key,
const char *const  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument cstring_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 711 of file variant_char.c.

713  {
714  amxc_var_t* subvar = NULL;
715 
716  when_null(var, exit);
717  subvar = amxc_var_add_new_key(var, key);
718  when_null(subvar, exit);
719 
720  if(amxc_var_set_cstring_t(subvar, val) != 0) {
721  amxc_var_delete(&subvar);
722  }
723 
724 exit:
725  return subvar;
726 }

◆ amxc_var_add_new_key_csv_string_t()

amxc_var_t* amxc_var_add_new_key_csv_string_t ( amxc_var_t *const  var,
const char *  key,
const char *const  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument csv_string_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 728 of file variant_char.c.

730  {
731  amxc_var_t* subvar = NULL;
732 
733  when_null(var, exit);
734  subvar = amxc_var_add_new_key(var, key);
735  when_null(subvar, exit);
736 
737  if(amxc_var_set_csv_string_t(subvar, val) != 0) {
738  amxc_var_delete(&subvar);
739  }
740 
741 exit:
742  return subvar;
743 }

◆ amxc_var_add_new_key_double()

amxc_var_t* amxc_var_add_new_key_double ( amxc_var_t *const  var,
const char *  key,
double  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument double
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 354 of file variant_double.c.

354  {
355  amxc_var_t* subvar = NULL;
356 
357  when_null(var, exit);
358  subvar = amxc_var_add_new_key(var, key);
359  when_null(subvar, exit);
360 
361  if(amxc_var_set_double(subvar, val) != 0) {
362  amxc_var_delete(&subvar);
363  }
364 
365 exit:
366  return subvar;
367 }

◆ amxc_var_add_new_key_fd_t()

amxc_var_t* amxc_var_add_new_key_fd_t ( amxc_var_t *const  var,
const char *  key,
int  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument fd_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 343 of file variant_fd.c.

343  {
344  amxc_var_t* subvar = NULL;
345 
346  when_null(var, exit);
347  subvar = amxc_var_add_new_key(var, key);
348  when_null(subvar, exit);
349 
350  if(amxc_var_set_fd_t(subvar, val) != 0) {
351  amxc_var_delete(&subvar);
352  }
353 
354 exit:
355  return subvar;
356 }

◆ amxc_var_add_new_key_int16_t()

amxc_var_t* amxc_var_add_new_key_int16_t ( amxc_var_t *const  var,
const char *  key,
int16_t  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument int16_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 344 of file variant_int16.c.

344  {
345  amxc_var_t* subvar = NULL;
346 
347  when_null(var, exit);
348  subvar = amxc_var_add_new_key(var, key);
349  when_null(subvar, exit);
350 
351  if(amxc_var_set_int32_t(subvar, val) != 0) {
352  amxc_var_delete(&subvar);
353  }
354 
355 exit:
356  return subvar;
357 }

◆ amxc_var_add_new_key_int32_t()

amxc_var_t* amxc_var_add_new_key_int32_t ( amxc_var_t *const  var,
const char *  key,
int32_t  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument int32_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 349 of file variant_int32.c.

349  {
350  amxc_var_t* subvar = NULL;
351 
352  when_null(var, exit);
353  subvar = amxc_var_add_new_key(var, key);
354  when_null(subvar, exit);
355 
356  if(amxc_var_set_int32_t(subvar, val) != 0) {
357  amxc_var_delete(&subvar);
358  }
359 
360 exit:
361  return subvar;
362 }

◆ amxc_var_add_new_key_int64_t()

amxc_var_t* amxc_var_add_new_key_int64_t ( amxc_var_t *const  var,
const char *  key,
int64_t  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument int64_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 356 of file variant_int64.c.

356  {
357  amxc_var_t* subvar = NULL;
358 
359  when_null(var, exit);
360  subvar = amxc_var_add_new_key(var, key);
361  when_null(subvar, exit);
362 
363  if(amxc_var_set_int64_t(subvar, val) != 0) {
364  amxc_var_delete(&subvar);
365  }
366 
367 exit:
368  return subvar;
369 }

◆ amxc_var_add_new_key_int8_t()

amxc_var_t* amxc_var_add_new_key_int8_t ( amxc_var_t *const  var,
const char *  key,
int8_t  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument int8_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 331 of file variant_int8.c.

331  {
332  amxc_var_t* subvar = NULL;
333 
334  when_null(var, exit);
335  subvar = amxc_var_add_new_key(var, key);
336  when_null(subvar, exit);
337 
338  if(amxc_var_set_int32_t(subvar, val) != 0) {
339  amxc_var_delete(&subvar);
340  }
341 
342 exit:
343  return subvar;
344 }

◆ amxc_var_add_new_key_ssv_string_t()

amxc_var_t* amxc_var_add_new_key_ssv_string_t ( amxc_var_t *const  var,
const char *  key,
const char *const  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument ssv_string_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 745 of file variant_char.c.

747  {
748  amxc_var_t* subvar = NULL;
749 
750  when_null(var, exit);
751  subvar = amxc_var_add_new_key(var, key);
752  when_null(subvar, exit);
753 
754  if(amxc_var_set_ssv_string_t(subvar, val) != 0) {
755  amxc_var_delete(&subvar);
756  }
757 
758 exit:
759  return subvar;
760 }
int amxc_var_set_ssv_string_t(amxc_var_t *const var, const char *const val)
Setter helper function.
Definition: variant_char.c:573

◆ amxc_var_add_new_key_uint16_t()

amxc_var_t* amxc_var_add_new_key_uint16_t ( amxc_var_t *const  var,
const char *  key,
uint16_t  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument uint16_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 346 of file variant_uint16.c.

346  {
347  amxc_var_t* subvar = NULL;
348 
349  when_null(var, exit);
350  subvar = amxc_var_add_new_key(var, key);
351  when_null(subvar, exit);
352 
353  if(amxc_var_set_uint16_t(subvar, val) != 0) {
354  amxc_var_delete(&subvar);
355  }
356 
357 exit:
358  return subvar;
359 }
int amxc_var_set_uint16_t(amxc_var_t *var, uint16_t val)
Setter helper function.

◆ amxc_var_add_new_key_uint32_t()

amxc_var_t* amxc_var_add_new_key_uint32_t ( amxc_var_t *const  var,
const char *  key,
uint32_t  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument uint32_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 355 of file variant_uint32.c.

355  {
356  amxc_var_t* subvar = NULL;
357 
358  when_null(var, exit);
359  subvar = amxc_var_add_new_key(var, key);
360  when_null(subvar, exit);
361 
362  if(amxc_var_set_uint32_t(subvar, val) != 0) {
363  amxc_var_delete(&subvar);
364  }
365 
366 exit:
367  return subvar;
368 }
int amxc_var_set_uint32_t(amxc_var_t *var, uint32_t val)
Setter helper function.

◆ amxc_var_add_new_key_uint64_t()

amxc_var_t* amxc_var_add_new_key_uint64_t ( amxc_var_t *const  var,
const char *  key,
uint64_t  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument uint64_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 363 of file variant_uint64.c.

363  {
364  amxc_var_t* subvar = NULL;
365 
366  when_null(var, exit);
367  subvar = amxc_var_add_new_key(var, key);
368  when_null(subvar, exit);
369 
370  if(amxc_var_set_uint64_t(subvar, val) != 0) {
371  amxc_var_delete(&subvar);
372  }
373 
374 exit:
375  return subvar;
376 }
int amxc_var_set_uint64_t(amxc_var_t *var, uint64_t val)
Setter helper function.

◆ amxc_var_add_new_key_uint8_t()

amxc_var_t* amxc_var_add_new_key_uint8_t ( amxc_var_t *const  var,
const char *  key,
uint8_t  val 
)

Conversion helper function.

See also
amxc_var_add_key

Creates a new variant and adds it to a composite variant that supports key addressing.

Note
Do not call this function directly, use macro amxc_var_add_key with the type argument uint8_t
Parameters
varpointer to a variant struct
keythe key
valthe new value
Returns
The new variant

Definition at line 339 of file variant_uint8.c.

339  {
340  amxc_var_t* subvar = NULL;
341 
342  when_null(var, exit);
343  subvar = amxc_var_add_new_key(var, key);
344  when_null(subvar, exit);
345 
346  if(amxc_var_set_uint8_t(subvar, val) != 0) {
347  amxc_var_delete(&subvar);
348  }
349 
350 exit:
351  return subvar;
352 }
int amxc_var_set_uint8_t(amxc_var_t *var, uint8_t val)
Setter helper function.

◆ amxc_var_add_new_ssv_string_t()

amxc_var_t* amxc_var_add_new_ssv_string_t ( amxc_var_t *const  var,
const char *const  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument ssv_string_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 696 of file variant_char.c.

696  {
697  amxc_var_t* subvar = NULL;
698 
699  when_null(var, exit);
700  subvar = amxc_var_add_new(var);
701  when_null(subvar, exit);
702 
703  if(amxc_var_set_csv_string_t(subvar, val) != 0) {
704  amxc_var_delete(&subvar);
705  }
706 
707 exit:
708  return subvar;
709 }

◆ amxc_var_add_new_uint16_t()

amxc_var_t* amxc_var_add_new_uint16_t ( amxc_var_t *const  var,
uint16_t  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument uint16_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 331 of file variant_uint16.c.

331  {
332  amxc_var_t* subvar = NULL;
333 
334  when_null(var, exit);
335  subvar = amxc_var_add_new(var);
336  when_null(subvar, exit);
337 
338  if(amxc_var_set_uint16_t(subvar, val) != 0) {
339  amxc_var_delete(&subvar);
340  }
341 
342 exit:
343  return subvar;
344 }

◆ amxc_var_add_new_uint32_t()

amxc_var_t* amxc_var_add_new_uint32_t ( amxc_var_t *const  var,
uint32_t  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument uint32_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 340 of file variant_uint32.c.

340  {
341  amxc_var_t* subvar = NULL;
342 
343  when_null(var, exit);
344  subvar = amxc_var_add_new(var);
345  when_null(subvar, exit);
346 
347  if(amxc_var_set_uint32_t(subvar, val) != 0) {
348  amxc_var_delete(&subvar);
349  }
350 
351 exit:
352  return subvar;
353 }

◆ amxc_var_add_new_uint64_t()

amxc_var_t* amxc_var_add_new_uint64_t ( amxc_var_t *const  var,
uint64_t  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument uint64_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 348 of file variant_uint64.c.

348  {
349  amxc_var_t* subvar = NULL;
350 
351  when_null(var, exit);
352  subvar = amxc_var_add_new(var);
353  when_null(subvar, exit);
354 
355  if(amxc_var_set_uint64_t(subvar, val) != 0) {
356  amxc_var_delete(&subvar);
357  }
358 
359 exit:
360  return subvar;
361 }

◆ amxc_var_add_new_uint8_t()

amxc_var_t* amxc_var_add_new_uint8_t ( amxc_var_t *const  var,
uint8_t  val 
)

Conversion helper function.

See also
amxc_var_add

Creates a new variant and adds it to a composite variant that supports index addressing.

Note
Do not call this function directly, use macro amxc_var_add with the type argument uint8_t
Parameters
varpointer to a variant struct
valthe value
Returns
The new variant

Definition at line 324 of file variant_uint8.c.

324  {
325  amxc_var_t* subvar = NULL;
326 
327  when_null(var, exit);
328  subvar = amxc_var_add_new(var);
329  when_null(subvar, exit);
330 
331  if(amxc_var_set_uint8_t(subvar, val) != 0) {
332  amxc_var_delete(&subvar);
333  }
334 
335 exit:
336  return subvar;
337 }

◆ amxc_var_get_amxc_htable_t()

amxc_htable_t* amxc_var_get_amxc_htable_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument amxc_htable_t
Parameters
varpointer to a variant struct
Returns
amxc_htable_t* value, must be freed when not needed anymore

Definition at line 417 of file variant_htable.c.

417  {
418  amxc_htable_t* htable = NULL;
419  amxc_htable_it_t* it = NULL;
420  amxc_var_t variant;
421  when_null(var, exit);
422 
423  amxc_var_init(&variant);
425 
426  if(amxc_htable_new(&htable, amxc_htable_capacity(&variant.data.vm)) != 0) {
427  amxc_var_clean(&variant);
428  goto exit;
429  }
430 
431  it = amxc_htable_take_first(&variant.data.vm);
432  while(it != NULL) {
433  const char* key = amxc_htable_it_get_key(it);
435  it = amxc_htable_take_first(&variant.data.vm);
436  }
437 
438  amxc_var_clean(&variant);
439 
440 exit:
441  return htable;
442 }
#define when_failed(x, l)
Definition: amxc_macros.h:142
AMXC_INLINE const char * amxc_htable_it_get_key(const amxc_htable_it_t *const it)
Gets the key from the iterator.
Definition: amxc_htable.h:672
int amxc_htable_new(amxc_htable_t **htable, const size_t reserve)
Allocates a hash table.
Definition: amxc_htable.c:148
AMXC_INLINE size_t amxc_htable_capacity(const amxc_htable_t *const htable)
Calculates the capacity of the hash table.
Definition: amxc_htable.h:351
AMXC_INLINE amxc_htable_it_t * amxc_htable_take_first(const amxc_htable_t *const htable)
Removes the first item stored in the table.
Definition: amxc_htable.h:696
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.
Definition: amxc_htable.c:237
int amxc_var_init(amxc_var_t *const var)
Initializes a variant.
Definition: amxc_variant.c:223
void amxc_var_clean(amxc_var_t *const var)
Clean-up and reset variant.
Definition: amxc_variant.c:237
int amxc_var_convert(amxc_var_t *const dest, const amxc_var_t *src, const uint32_t type_id)
Converts one variant (source) to another variant(destination) using the specified variant type id.
Definition: amxc_variant.c:333
The hash table iterator structure.
Definition: amxc_htable.h:138
The hash table structure.
Definition: amxc_htable.h:175
void * data
Definition: amxc_variant.h:883
static amxc_htable_it_t it[2000]

◆ amxc_var_get_amxc_llist_t()

amxc_llist_t* amxc_var_get_amxc_llist_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument amxc_llist_t
Parameters
varpointer to a variant struct
Returns
amxc_llist_t* value, must be freed when not needed anymore

Definition at line 385 of file variant_list.c.

385  {
386  amxc_llist_t* llist = NULL;
387  amxc_llist_it_t* it = NULL;
388  amxc_var_t variant;
389  when_null(var, exit);
390 
391  amxc_var_init(&variant);
393 
394  if(amxc_llist_new(&llist) != 0) {
395  amxc_var_clean(&variant);
396  goto exit;
397  }
398 
399  it = amxc_llist_take_first(&variant.data.vl);
400  while(it != NULL) {
402  it = amxc_llist_take_first(&variant.data.vl);
403  }
404 
405  amxc_var_clean(&variant);
406 
407 exit:
408  return llist;
409 }
int amxc_llist_new(amxc_llist_t **llist)
Allocates a linked list.
Definition: amxc_llist.c:88
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.
Definition: amxc_llist.c:169
AMXC_INLINE amxc_llist_it_t * amxc_llist_take_first(amxc_llist_t *const llist)
Removes the first item from the linked list.
Definition: amxc_llist.h:752
The linked list iterator structure.
Definition: amxc_llist.h:215
The linked list structure.
Definition: amxc_llist.h:228
static amxc_llist_t * llist

◆ amxc_var_get_amxc_ts_t()

amxc_ts_t* amxc_var_get_amxc_ts_t ( const amxc_var_t var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument amxc_ts_t
Parameters
varpointer to a variant struct
Returns
amxc_ts_t* value, must be freed when not needed anymore

Definition at line 182 of file variant_timestamp.c.

182  {
183  amxc_ts_t* ts = NULL;
184  amxc_var_t variant;
185  when_null(var, exit);
186 
187  amxc_var_init(&variant);
189  ts = (amxc_ts_t*) calloc(1, sizeof(amxc_ts_t));
190  when_null(ts, exit);
191 
192  ts->sec = variant.data.ts.sec;
193  ts->nsec = variant.data.ts.nsec;
194  ts->offset = variant.data.ts.offset;
195 
196  amxc_var_clean(&variant);
197 
198 exit:
199  return ts;
200 }
The timestamp structure (unix epoch time).
int32_t nsec
int16_t offset

◆ amxc_var_get_bool()

bool amxc_var_get_bool ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument bool
Parameters
varpointer to a variant struct
Returns
boolean value

Definition at line 234 of file variant_bool.c.

234  {
235  bool boolean = false;
236  amxc_var_t variant;
237  when_null(var, exit);
238 
239  amxc_var_init(&variant);
241  boolean = variant.data.b;
242  amxc_var_clean(&variant);
243 
244 exit:
245  return boolean;
246 }
#define AMXC_VAR_ID_BOOL
Boolean variant id.
Definition: amxc_variant.h:200

◆ amxc_var_get_const_amxc_htable_t()

const amxc_htable_t* amxc_var_get_const_amxc_htable_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return NULL if the variant is not of a table type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument amxc_htable_t
do not free the returned pointer.
Parameters
varpointer to a variant struct
Returns
amxc_htable_t* value

Definition at line 444 of file variant_htable.c.

444  {
445  const amxc_htable_t* retval = NULL;
446  when_null(var, exit);
448 
449  retval = &var->data.vm;
450 
451 exit:
452  return retval;
453 }
#define when_true(x, l)
Definition: amxc_macros.h:134
uint32_t type_id
Definition: amxc_variant.h:864

◆ amxc_var_get_const_amxc_llist_t()

const amxc_llist_t* amxc_var_get_const_amxc_llist_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return NULL if the variant is not of a list type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument amxc_llist_t
do not free the returned pointer.
Parameters
varpointer to a variant struct
Returns
amxc_llist_t* value

Definition at line 411 of file variant_list.c.

411  {
412  const amxc_llist_t* retval = NULL;
413  when_null(var, exit);
415 
416  retval = &var->data.vl;
417 
418 exit:
419  return retval;
420 }

◆ amxc_var_get_const_amxc_ts_t()

const amxc_ts_t* amxc_var_get_const_amxc_ts_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return NULL if the variant is not of a timestamp type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument ts_t
Parameters
varpointer to a variant struct
Returns
amxc_ts_t* value

Definition at line 202 of file variant_timestamp.c.

202  {
203  const amxc_ts_t* retval = NULL;
204  when_null(var, exit);
206 
207  retval = &var->data.ts;
208 
209 exit:
210  return retval;
211 }

◆ amxc_var_get_const_bool()

bool amxc_var_get_const_bool ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return false if the variant is not of a bool type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument bool
do not free the returned pointer.
Parameters
varpointer to a variant struct
Returns
bool value

Definition at line 248 of file variant_bool.c.

248  {
249  bool retval = false;
250  when_null(var, exit);
252 
253  retval = var->data.b;
254 
255 exit:
256  return retval;
257 }

◆ amxc_var_get_const_cstring_t()

const char* amxc_var_get_const_cstring_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return NULL if the variant is not of a string type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument cstring_t
do not free the returned pointer.
Parameters
varpointer to a variant struct
Returns
char* value

Definition at line 600 of file variant_char.c.

600  {
601  const char* retval = NULL;
602  when_null(var, exit);
606 
607  retval = var->data.s == NULL ? "" : var->data.s;
608 
609 exit:
610  return retval;
611 }
#define AMXC_VAR_ID_CSTRING
C-string variant id (aka char *), null terminated string.
Definition: amxc_variant.h:134
#define AMXC_VAR_ID_SSV_STRING
Space Separated Values string variant id.
Definition: amxc_variant.h:236
#define AMXC_VAR_ID_CSV_STRING
Comma Separated Values string variant id.
Definition: amxc_variant.h:230

◆ amxc_var_get_const_csv_string_t()

AMXC_INLINE const char* amxc_var_get_const_csv_string_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return NULL if the variant is not of a cstring_t type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument csv_string_t
Parameters
varpointer to a variant struct
Returns
char* value

Definition at line 2576 of file amxc_variant.h.

2576  {
2578 }
const char * amxc_var_get_const_cstring_t(const amxc_var_t *const var)
Conversion helper function.
Definition: variant_char.c:600

◆ amxc_var_get_const_double()

double amxc_var_get_const_double ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return 0 if the variant is not of a double type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument double
Parameters
varpointer to a variant struct
Returns
double value

Definition at line 328 of file variant_double.c.

328  {
329  double retval = 0;
330  when_null(var, exit);
332 
333  retval = var->data.d;
334 
335 exit:
336  return retval;
337 }
#define AMXC_VAR_ID_DOUBLE
Double variant id.
Definition: amxc_variant.h:194

◆ amxc_var_get_const_fd_t()

int amxc_var_get_const_fd_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return 0 if the variant is not of a fd type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument fd_t
Parameters
varpointer to a variant struct
Returns
file descriptor value

Definition at line 317 of file variant_fd.c.

317  {
318  fd_t retval = -1;
319  when_null(var, exit);
320  when_true(var->type_id != AMXC_VAR_ID_FD, exit);
321 
322  retval = var->data.fd;
323 
324 exit:
325  return retval;
326 }
#define fd_t
Convenience macro.
Definition: amxc_variant.h:600
#define AMXC_VAR_ID_FD
File descriptor variant id.
Definition: amxc_variant.h:218

◆ amxc_var_get_const_int16_t()

int16_t amxc_var_get_const_int16_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return 0 if the variant is not of a int16_t type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument int16_t
Parameters
varpointer to a variant struct
Returns
int16_t value

Definition at line 318 of file variant_int16.c.

318  {
319  int16_t retval = 0;
320  when_null(var, exit);
322 
323  retval = var->data.i16;
324 
325 exit:
326  return retval;
327 }
#define AMXC_VAR_ID_INT16
Signed 16 bit integer variant id.
Definition: amxc_variant.h:146

◆ amxc_var_get_const_int32_t()

int32_t amxc_var_get_const_int32_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return 0 if the variant is not of a int32_t type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument int32_t
Parameters
varpointer to a variant struct
Returns
int32_t value

Definition at line 323 of file variant_int32.c.

323  {
324  int32_t retval = 0;
325  when_null(var, exit);
327 
328  retval = var->data.i32;
329 
330 exit:
331  return retval;
332 }
#define AMXC_VAR_ID_INT32
Signed 32 bit integer variant id.
Definition: amxc_variant.h:152

◆ amxc_var_get_const_int64_t()

int64_t amxc_var_get_const_int64_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return 0 if the variant is not of a int64_t type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument int64_t
Parameters
varpointer to a variant struct
Returns
int64_t value

Definition at line 330 of file variant_int64.c.

330  {
331  int64_t retval = 0;
332  when_null(var, exit);
334 
335  retval = var->data.i64;
336 
337 exit:
338  return retval;
339 }
#define AMXC_VAR_ID_INT64
Signed 64 bit integer variant id.
Definition: amxc_variant.h:158

◆ amxc_var_get_const_int8_t()

int8_t amxc_var_get_const_int8_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return 0 if the variant is not of a int8_t type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument int8_t
Parameters
varpointer to a variant struct
Returns
int8_t value

Definition at line 305 of file variant_int8.c.

305  {
306  int8_t retval = 0;
307  when_null(var, exit);
309 
310  retval = var->data.i8;
311 
312 exit:
313  return retval;
314 }
#define AMXC_VAR_ID_INT8
Signed 8 bit integer variant id.
Definition: amxc_variant.h:140

◆ amxc_var_get_const_ssv_string_t()

AMXC_INLINE const char* amxc_var_get_const_ssv_string_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return NULL if the variant is not of a cstring_t type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument ssv_string_t
Parameters
varpointer to a variant struct
Returns
char* value

Definition at line 2599 of file amxc_variant.h.

2599  {
2601 }

◆ amxc_var_get_const_uint16_t()

uint16_t amxc_var_get_const_uint16_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return 0 if the variant is not of a uint16_t type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument uint16_t
Parameters
varpointer to a variant struct
Returns
uint16_t value

Definition at line 320 of file variant_uint16.c.

320  {
321  uint32_t retval = 0;
322  when_null(var, exit);
324 
325  retval = var->data.ui16;
326 
327 exit:
328  return retval;
329 }
#define AMXC_VAR_ID_UINT16
Unsigned 16 bit integer variant id.
Definition: amxc_variant.h:170

◆ amxc_var_get_const_uint32_t()

uint32_t amxc_var_get_const_uint32_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return 0 if the variant is not of a uint32_t type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument uint32_t
Parameters
varpointer to a variant struct
Returns
uint32_t value

Definition at line 329 of file variant_uint32.c.

329  {
330  uint32_t retval = 0;
331  when_null(var, exit);
333 
334  retval = var->data.ui32;
335 
336 exit:
337  return retval;
338 }
#define AMXC_VAR_ID_UINT32
Unsigned 32 bit integer variant id.
Definition: amxc_variant.h:176

◆ amxc_var_get_const_uint64_t()

uint64_t amxc_var_get_const_uint64_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return 0 if the variant is not of a uint64_t type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument uint64_t
Parameters
varpointer to a variant struct
Returns
uint64_t value

Definition at line 337 of file variant_uint64.c.

337  {
338  uint64_t retval = 0;
339  when_null(var, exit);
341 
342  retval = var->data.ui64;
343 
344 exit:
345  return retval;
346 }
#define AMXC_VAR_ID_UINT64
Unsigned 64 bit integer variant id.
Definition: amxc_variant.h:182

◆ amxc_var_get_const_uint8_t()

uint8_t amxc_var_get_const_uint8_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_constcast

Will return 0 if the variant is not of a uint8_t type

Note
Do not call this function directly, use macro amxc_var_constcast with the type argument uint8_t
Parameters
varpointer to a variant struct
Returns
uint8_t value

Definition at line 313 of file variant_uint8.c.

313  {
314  uint32_t retval = 0;
315  when_null(var, exit);
317 
318  retval = var->data.ui8;
319 
320 exit:
321  return retval;
322 }
#define AMXC_VAR_ID_UINT8
Unsigned 8 bit integer variant id.
Definition: amxc_variant.h:164

◆ amxc_var_get_cstring_t()

char* amxc_var_get_cstring_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument cstring_t
Parameters
varpointer to a variant struct
Returns
char* value, must be freed when not needed anymore

Definition at line 585 of file variant_char.c.

585  {
586  char* retval = NULL;
587  amxc_var_t variant;
588  when_null(var, exit);
589 
590  amxc_var_init(&variant);
592  retval = variant.data.s != NULL ? variant.data.s : strdup("");
593  variant.data.s = NULL;
594  amxc_var_clean(&variant);
595 
596 exit:
597  return retval;
598 }

◆ amxc_var_get_csv_string_t()

AMXC_INLINE char* amxc_var_get_csv_string_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument csv_string_t
Parameters
varpointer to a variant struct
Returns
char* value, must be freed when not needed anymore

Definition at line 2234 of file amxc_variant.h.

2234  {
2235  return amxc_var_get_cstring_t(var);
2236 }
char * amxc_var_get_cstring_t(const amxc_var_t *const var)
Conversion helper function.
Definition: variant_char.c:585

◆ amxc_var_get_double()

double amxc_var_get_double ( const amxc_var_t var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument double
Parameters
varpointer to a variant struct
Returns
double value

Definition at line 313 of file variant_double.c.

313  {
314  double retval = 0;
315  amxc_var_t variant;
316 
317  when_null(var, exit);
318 
319  amxc_var_init(&variant);
321  retval = variant.data.d;
322  amxc_var_clean(&variant);
323 
324 exit:
325  return retval;
326 }

◆ amxc_var_get_fd_t()

int amxc_var_get_fd_t ( const amxc_var_t var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument fd_t
Parameters
varpointer to a variant struct
Returns
int value

Definition at line 303 of file variant_fd.c.

303  {
304  int64_t retval = 0;
305  amxc_var_t variant;
306  when_null(var, exit);
307 
308  amxc_var_init(&variant);
309  when_failed(amxc_var_convert(&variant, var, AMXC_VAR_ID_FD), exit);
310  retval = variant.data.fd;
311  amxc_var_clean(&variant);
312 
313 exit:
314  return retval;
315 }

◆ amxc_var_get_int16_t()

int16_t amxc_var_get_int16_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument int16_t
Parameters
varpointer to a variant struct
Returns
int16_t value

Definition at line 304 of file variant_int16.c.

304  {
305  int16_t retval = 0;
306  amxc_var_t variant;
307  when_null(var, exit);
308 
309  amxc_var_init(&variant);
311  retval = variant.data.i16;
312  amxc_var_clean(&variant);
313 
314 exit:
315  return retval;
316 }

◆ amxc_var_get_int32_t()

int32_t amxc_var_get_int32_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument int32_t
Parameters
varpointer to a variant struct
Returns
int32_t value

Definition at line 309 of file variant_int32.c.

309  {
310  int32_t retval = 0;
311  amxc_var_t variant;
312  when_null(var, exit);
313 
314  amxc_var_init(&variant);
316  retval = variant.data.i32;
317  amxc_var_clean(&variant);
318 
319 exit:
320  return retval;
321 }

◆ amxc_var_get_int64_t()

int64_t amxc_var_get_int64_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument int64_t
Parameters
varpointer to a variant struct
Returns
int64_t value

Definition at line 316 of file variant_int64.c.

316  {
317  int64_t retval = 0;
318  amxc_var_t variant;
319  when_null(var, exit);
320 
321  amxc_var_init(&variant);
323  retval = variant.data.i64;
324  amxc_var_clean(&variant);
325 
326 exit:
327  return retval;
328 }

◆ amxc_var_get_int8_t()

int8_t amxc_var_get_int8_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument int8_t
Parameters
varpointer to a variant struct
Returns
int8_t value

Definition at line 291 of file variant_int8.c.

291  {
292  int8_t retval = 0;
293  amxc_var_t variant;
294  when_null(var, exit);
295 
296  amxc_var_init(&variant);
298  retval = variant.data.i8;
299  amxc_var_clean(&variant);
300 
301 exit:
302  return retval;
303 }

◆ amxc_var_get_ssv_string_t()

AMXC_INLINE char* amxc_var_get_ssv_string_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument ssv_string_t
Parameters
varpointer to a variant struct
Returns
char* value, must be freed when not needed anymore

Definition at line 2255 of file amxc_variant.h.

2255  {
2256  return amxc_var_get_cstring_t(var);
2257 }

◆ amxc_var_get_uint16_t()

uint16_t amxc_var_get_uint16_t ( const amxc_var_t var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument uint16_t
Parameters
varpointer to a variant struct
Returns
uint16_t value

Definition at line 306 of file variant_uint16.c.

306  {
307  uint32_t retval = 0;
308  amxc_var_t variant;
309  when_null(var, exit);
310 
311  amxc_var_init(&variant);
313  retval = variant.data.ui16;
314  amxc_var_clean(&variant);
315 
316 exit:
317  return retval;
318 }

◆ amxc_var_get_uint32_t()

uint32_t amxc_var_get_uint32_t ( const amxc_var_t var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument uint32_t
Parameters
varpointer to a variant struct
Returns
uint32_t value

Definition at line 315 of file variant_uint32.c.

315  {
316  uint32_t retval = 0;
317  amxc_var_t variant;
318  when_null(var, exit);
319 
320  amxc_var_init(&variant);
322  retval = variant.data.ui32;
323  amxc_var_clean(&variant);
324 
325 exit:
326  return retval;
327 }

◆ amxc_var_get_uint64_t()

uint64_t amxc_var_get_uint64_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument uint64_t
Parameters
varpointer to a variant struct
Returns
uint64_t value

Definition at line 323 of file variant_uint64.c.

323  {
324  uint64_t retval = 0;
325  amxc_var_t variant;
326  when_null(var, exit);
327 
328  amxc_var_init(&variant);
330  retval = variant.data.ui64;
331  amxc_var_clean(&variant);
332 
333 exit:
334  return retval;
335 }

◆ amxc_var_get_uint8_t()

uint8_t amxc_var_get_uint8_t ( const amxc_var_t *const  var)

Conversion helper function.

See also
amxc_var_dyncast
Note
Do not call this function directly, use macro amxc_var_dyncast with the type argument uint8_t
Parameters
varpointer to a variant struct
Returns
uint8_t value

Definition at line 299 of file variant_uint8.c.

299  {
300  uint32_t retval = 0;
301  amxc_var_t variant;
302  when_null(var, exit);
303 
304  amxc_var_init(&variant);
306  retval = variant.data.ui8;
307  amxc_var_clean(&variant);
308 
309 exit:
310  return retval;
311 }

◆ amxc_var_push_amxc_string_t()

int amxc_var_push_amxc_string_t ( amxc_var_t *const  var,
amxc_string_t val 
)

Pushes a value in a variant.

See also
amxc_var_push
Note
Do not call this function directly, use macro amxc_var_push with the type argument amxc_string_t
Parameters
varpointer to a variant struct
valthe value that is pushed into the variant
Returns
0 when succesful

Definition at line 696 of file amxc_variant.c.

696  {
697  int retval = -1;
698  char* buffer = NULL;
699 
700  when_null(var, exit);
701  when_null(val, exit);
702 
704 
705  buffer = amxc_string_take_buffer(val);
706  retval = amxc_var_push_cstring_t(var, buffer);
707 
708 exit:
709  return retval;
710 }
char * amxc_string_take_buffer(amxc_string_t *const string)
Takes the string buffer.
Definition: amxc_string.c:356
int amxc_var_push_cstring_t(amxc_var_t *const var, char *val)
Pushes a value in a variant.
Definition: variant_char.c:629

◆ amxc_var_push_cstring_t()

int amxc_var_push_cstring_t ( amxc_var_t *const  var,
char *  val 
)

Pushes a value in a variant.

See also
amxc_var_push
Note
Do not call this function directly, use macro amxc_var_push with the type argument cstring_t
Parameters
varpointer to a variant struct
valthe value that is pushed into the variant
Returns
0 when succesful

Definition at line 629 of file variant_char.c.

629  {
630  int retval = -1;
631 
632  when_null(var, exit);
634 
636  var->data.s = val;
637 
638  retval = 0;
639 
640 exit:
641  return retval;
642 }

◆ amxc_var_push_csv_string_t()

int amxc_var_push_csv_string_t ( amxc_var_t *const  var,
char *  val 
)

Pushes a value in a variant.

See also
amxc_var_push
Note
Do not call this function directly, use macro amxc_var_push with the type argument csv_string_t
Parameters
varpointer to a variant struct
valthe value that is pushed into the variant
Returns
0 when succesful

Definition at line 644 of file variant_char.c.

644  {
645  int retval = -1;
646 
647  retval = amxc_var_push_cstring_t(var, val);
648  if(retval == 0) {
650  }
651 
652  return retval;
653 }

◆ amxc_var_push_ssv_string_t()

int amxc_var_push_ssv_string_t ( amxc_var_t *const  var,
char *  val 
)

Pushes a value in a variant.

See also
amxc_var_push
Note
Do not call this function directly, use macro amxc_var_push with the type argument ssv_string_t
Parameters
varpointer to a variant struct
valthe value that is pushed into the variant
Returns
0 when succesful

Definition at line 655 of file variant_char.c.

655  {
656  int retval = -1;
657 
658  retval = amxc_var_push_cstring_t(var, val);
659  if(retval == 0) {
661  }
662 
663  return retval;
664 }

◆ amxc_var_set_amxc_ts_t()

int amxc_var_set_amxc_ts_t ( amxc_var_t var,
amxc_ts_t val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument amxc_ts_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 165 of file variant_timestamp.c.

165  {
166  int retval = -1;
167  when_null(var, exit);
168  when_null(ts, exit);
169 
171 
172  var->data.ts.sec = ts->sec;
173  var->data.ts.nsec = ts->nsec;
174  var->data.ts.offset = ts->offset;
175 
176  retval = 0;
177 
178 exit:
179  return retval;
180 }

◆ amxc_var_set_bool()

int amxc_var_set_bool ( amxc_var_t *const  var,
bool  boolean 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument bool
Parameters
varpointer to a variant struct
booleanthe bool value to set, either true or false
Returns
0 when the value was set

Definition at line 221 of file variant_bool.c.

221  {
222  int retval = -1;
223  when_null(var, exit);
224 
226 
227  var->data.b = boolean;
228  retval = 0;
229 
230 exit:
231  return retval;
232 }

◆ amxc_var_set_cstring_t()

int amxc_var_set_cstring_t ( amxc_var_t *const  var,
const char *const  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument cstring_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 549 of file variant_char.c.

549  {
550  int retval = -1;
551  when_null(var, exit);
552  when_null(val, exit);
554 
555  retval = amxc_var_set_data(var, val);
556 
557 exit:
558  return retval;
559 }
static int amxc_var_set_data(amxc_var_t *const var, const char *const val)
Definition: variant_char.c:532

◆ amxc_var_set_csv_string_t()

int amxc_var_set_csv_string_t ( amxc_var_t *const  var,
const char *const  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument csv_string_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 561 of file variant_char.c.

561  {
562  int retval = -1;
563  when_null(var, exit);
564  when_null(val, exit);
566 
567  retval = amxc_var_set_data(var, val);
568 
569 exit:
570  return retval;
571 }

◆ amxc_var_set_double()

int amxc_var_set_double ( amxc_var_t var,
double  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument double
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 300 of file variant_double.c.

300  {
301  int retval = -1;
302  when_null(var, exit);
303 
305 
306  var->data.d = val;
307  retval = 0;
308 
309 exit:
310  return retval;
311 }

◆ amxc_var_set_fd_t()

int amxc_var_set_fd_t ( amxc_var_t var,
int  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument fd_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 285 of file variant_fd.c.

285  {
286  int retval = -1;
287  struct rlimit nofile = { 0, 0 };
288  when_null(var, exit);
289 
290  when_failed(getrlimit(RLIMIT_NOFILE, &nofile), exit);
291 
292  when_true(val < 0 || (rlim_t) llabs(val) > nofile.rlim_max, exit);
294 
295  var->data.fd = (int) llabs(val);
296 
297  retval = 0;
298 
299 exit:
300  return retval;
301 }

◆ amxc_var_set_int16_t()

int amxc_var_set_int16_t ( amxc_var_t *const  var,
int16_t  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument int16_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 291 of file variant_int16.c.

291  {
292  int retval = -1;
293  when_null(var, exit);
294 
296 
297  var->data.i16 = val;
298  retval = 0;
299 
300 exit:
301  return retval;
302 }

◆ amxc_var_set_int32_t()

int amxc_var_set_int32_t ( amxc_var_t *const  var,
int32_t  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument int32_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 296 of file variant_int32.c.

296  {
297  int retval = -1;
298  when_null(var, exit);
299 
301 
302  var->data.i32 = val;
303  retval = 0;
304 
305 exit:
306  return retval;
307 }

◆ amxc_var_set_int64_t()

int amxc_var_set_int64_t ( amxc_var_t *const  var,
int64_t  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument int64_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 303 of file variant_int64.c.

303  {
304  int retval = -1;
305  when_null(var, exit);
306 
308 
309  var->data.i64 = val;
310  retval = 0;
311 
312 exit:
313  return retval;
314 }

◆ amxc_var_set_int8_t()

int amxc_var_set_int8_t ( amxc_var_t *const  var,
int8_t  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument int8_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 278 of file variant_int8.c.

278  {
279  int retval = -1;
280  when_null(var, exit);
281 
283 
284  var->data.i8 = val;
285  retval = 0;
286 
287 exit:
288  return retval;
289 }

◆ amxc_var_set_ssv_string_t()

int amxc_var_set_ssv_string_t ( amxc_var_t *const  var,
const char *const  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument ssv_string_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 573 of file variant_char.c.

573  {
574  int retval = -1;
575  when_null(var, exit);
576  when_null(val, exit);
578 
579  retval = amxc_var_set_data(var, val);
580 
581 exit:
582  return retval;
583 }

◆ amxc_var_set_uint16_t()

int amxc_var_set_uint16_t ( amxc_var_t *const  var,
uint16_t  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument uint16_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 293 of file variant_uint16.c.

293  {
294  int retval = -1;
295  when_null(var, exit);
296 
298 
299  var->data.ui16 = val;
300  retval = 0;
301 
302 exit:
303  return retval;
304 }

◆ amxc_var_set_uint32_t()

int amxc_var_set_uint32_t ( amxc_var_t *const  var,
uint32_t  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument uint16_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 302 of file variant_uint32.c.

302  {
303  int retval = -1;
304  when_null(var, exit);
305 
307 
308  var->data.ui32 = val;
309  retval = 0;
310 
311 exit:
312  return retval;
313 }

◆ amxc_var_set_uint64_t()

int amxc_var_set_uint64_t ( amxc_var_t *const  var,
uint64_t  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument uint64_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 310 of file variant_uint64.c.

310  {
311  int retval = -1;
312  when_null(var, exit);
313 
315 
316  var->data.ui64 = val;
317  retval = 0;
318 
319 exit:
320  return retval;
321 }

◆ amxc_var_set_uint8_t()

int amxc_var_set_uint8_t ( amxc_var_t *const  var,
uint8_t  val 
)

Setter helper function.

See also
amxc_var_set
Note
Do not call this function directly, use macro amxc_var_set with the type argument uint8_t
Parameters
varpointer to a variant struct
valthe value to set
Returns
0 when the value was set

Definition at line 286 of file variant_uint8.c.

286  {
287  int retval = -1;
288  when_null(var, exit);
289 
291 
292  var->data.ui8 = val;
293  retval = 0;
294 
295 exit:
296  return retval;
297 }

◆ amxc_var_take_amxc_string_t()

amxc_string_t* amxc_var_take_amxc_string_t ( amxc_var_t *const  var)

Takes a value from a variant.

See also
amxc_var_take
Note
Do not call this function directly, use macro amxc_var_take with the type argument amxc_string_t
Parameters
varpointer to a variant struct
Returns
char* value

Definition at line 676 of file amxc_variant.c.

676  {
677  amxc_string_t* retval = NULL;
678 
679  when_null(var, exit);
683  when_null(var->data.s, exit);
684 
685  when_failed(amxc_string_new(&retval, 0), exit);
686  when_null(retval, exit);
687 
688  amxc_string_push_buffer(retval, var->data.s, strlen(var->data.s) + 1);
689  var->data.s = NULL;
691 
692 exit:
693  return retval;
694 }
int amxc_string_push_buffer(amxc_string_t *const string, char *buffer, size_t length)
Sets the string buffer.
Definition: amxc_string.c:372
int amxc_string_new(amxc_string_t **string, const size_t length)
Allocates a string.
Definition: amxc_string.c:118
#define AMXC_VAR_ID_NULL
Null variant type id (aka void)
Definition: amxc_variant.h:128
uint32_t amxc_var_type_of(const amxc_var_t *const var)
Gets the variant type id of a variant.
Definition: amxc_variant.c:668
The string structure.
Definition: amxc_string.h:103

◆ amxc_var_take_cstring_t()

char* amxc_var_take_cstring_t ( amxc_var_t *const  var)

Takes a value from a variant.

See also
amxc_var_take
Note
Do not call this function directly, use macro amxc_var_take with the type argument cstring_t
Parameters
varpointer to a variant struct
Returns
char* value

Definition at line 613 of file variant_char.c.

613  {
614  char* retval = NULL;
615  when_null(var, exit);
619 
620  retval = var->data.s;
621 
622  var->data.s = NULL;
624 
625 exit:
626  return retval;
627 }

◆ amxc_var_take_csv_string_t()

AMXC_INLINE char* amxc_var_take_csv_string_t ( amxc_var_t *const  var)

Takes a value from a variant.

See also
amxc_var_take
Note
Do not call this function directly, use macro amxc_var_take with the type argument csv_string_t
Parameters
varpointer to a variant struct
Returns
char* value

Definition at line 3418 of file amxc_variant.h.

3418  {
3419  return amxc_var_take_cstring_t(var);
3420 }
char * amxc_var_take_cstring_t(amxc_var_t *const var)
Takes a value from a variant.
Definition: variant_char.c:613

◆ amxc_var_take_ssv_string_t()

AMXC_INLINE char* amxc_var_take_ssv_string_t ( amxc_var_t *const  var)

Takes a value from a variant.

See also
amxc_var_take
Note
Do not call this function directly, use macro amxc_var_take with the type argument ssv_string_t
Parameters
varpointer to a variant struct
Returns
char* value

Definition at line 3439 of file amxc_variant.h.

3439  {
3440  return amxc_var_take_cstring_t(var);
3441 }

◆ variant_htable_it_free()

void variant_htable_it_free ( const char *  key,
amxc_htable_it_t it 
)

Helper functions, can be used as delete function for htable.

When deleting an ambiorix htable and the htable contains only ambiorix variants, this function can be used as callback function to free all variants in the htable, see amxc_htable_delete.

Parameters
keythe key associated with the hash table iterator
itpointer to a variant htable iterator

◆ variant_list_it_free()

void variant_list_it_free ( amxc_llist_it_t it)

Helper functions, can be used as delete function for linked lists.

When deleting an ambiorix linked list and the linked list contains only ambiorix variants, this function can be used as callback function to free all variants in the linked list, see amxc_llist_delete

Parameters
itpointer to a variant linked list iterator

Definition at line 66 of file variant_list.c.

66  {
69 }
#define amxc_var_from_llist_it(ll_it)
Get the variant pointer from an amxc linked list iterator.
Definition: amxc_variant.h:799