All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Data Structures | Typedefs | Functions
as_list.h File Reference
#include <aerospike/as_bytes.h>
#include <aerospike/as_integer.h>
#include <aerospike/as_iterator.h>
#include <aerospike/as_string.h>
#include <aerospike/as_util.h>
#include <aerospike/as_val.h>
#include <stdbool.h>
#include <stdint.h>
+ Include dependency graph for as_list.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  as_list
 
struct  as_list_hooks
 

Typedefs

typedef bool(* as_list_foreach_callback) (as_val *value, void *udata)
 

Functions

static int as_list_append (as_list *list, as_val *value)
 
static int as_list_append_bytes (as_list *list, as_bytes *value)
 
static int as_list_append_int64 (as_list *list, int64_t value)
 
static int as_list_append_integer (as_list *list, as_integer *value)
 
static int as_list_append_list (as_list *list, as_list *value)
 
static int as_list_append_map (as_list *list, struct as_map_s *value)
 
static int as_list_append_str (as_list *list, const char *value)
 
static int as_list_append_string (as_list *list, as_string *value)
 
static int as_list_concat (as_list *list, const as_list *list2)
 
as_listas_list_cons (as_list *list, bool free, void *data, const as_list_hooks *hooks)
 
static void as_list_destroy (as_list *list)
 
static as_listas_list_drop (const as_list *list, uint32_t n)
 
static bool as_list_foreach (const as_list *list, as_list_foreach_callback callback, void *udata)
 
static as_listas_list_fromval (as_val *v)
 
static as_valas_list_get (const as_list *list, uint32_t i)
 
static as_bytesas_list_get_bytes (const as_list *list, uint32_t i)
 
static int64_t as_list_get_int64 (const as_list *list, uint32_t i)
 
static as_integeras_list_get_integer (const as_list *list, uint32_t i)
 
static as_listas_list_get_list (const as_list *list, uint32_t i)
 
static struct as_map_s * as_list_get_map (const as_list *list, uint32_t i)
 
static char * as_list_get_str (const as_list *list, uint32_t i)
 
static as_stringas_list_get_string (const as_list *list, uint32_t i)
 
static uint32_t as_list_hashcode (as_list *list)
 
static as_valas_list_head (const as_list *list)
 
as_listas_list_init (as_list *list, void *data, const as_list_hooks *hooks)
 
static int as_list_insert (as_list *list, uint32_t i, as_val *value)
 
static int as_list_insert_bytes (as_list *list, uint32_t i, as_bytes *value)
 
static int as_list_insert_int64 (as_list *list, uint32_t i, int64_t value)
 
static int as_list_insert_integer (as_list *list, uint32_t i, as_integer *value)
 
static int as_list_insert_list (as_list *list, uint32_t i, as_list *value)
 
static int as_list_insert_map (as_list *list, uint32_t i, struct as_map_s *value)
 
static int as_list_insert_str (as_list *list, uint32_t i, const char *value)
 
static int as_list_insert_string (as_list *list, uint32_t i, as_string *value)
 
static union as_list_iterator_u * as_list_iterator_init (union as_list_iterator_u *it, const as_list *list)
 
static union as_list_iterator_u * as_list_iterator_new (const as_list *list)
 
as_listas_list_new (void *data, const as_list_hooks *hooks)
 
static int as_list_prepend (as_list *list, as_val *value)
 
static int as_list_prepend_bytes (as_list *list, as_bytes *value)
 
static int as_list_prepend_int64 (as_list *list, int64_t value)
 
static int as_list_prepend_integer (as_list *list, as_integer *value)
 
static int as_list_prepend_list (as_list *list, as_list *value)
 
static int as_list_prepend_map (as_list *list, struct as_map_s *value)
 
static int as_list_prepend_str (as_list *list, const char *value)
 
static int as_list_prepend_string (as_list *list, as_string *value)
 
static int as_list_remove (as_list *list, uint32_t i)
 
static int as_list_set (as_list *list, uint32_t i, as_val *value)
 
static int as_list_set_bytes (as_list *list, uint32_t i, as_bytes *value)
 
static int as_list_set_int64 (as_list *list, uint32_t i, int64_t value)
 
static int as_list_set_integer (as_list *list, uint32_t i, as_integer *value)
 
static int as_list_set_list (as_list *list, uint32_t i, as_list *value)
 
static int as_list_set_map (as_list *list, uint32_t i, struct as_map_s *value)
 
static int as_list_set_str (as_list *list, uint32_t i, const char *value)
 
static int as_list_set_string (as_list *list, uint32_t i, as_string *value)
 
static uint32_t as_list_size (as_list *list)
 
static as_listas_list_tail (const as_list *list)
 
static as_listas_list_take (const as_list *list, uint32_t n)
 
static as_valas_list_toval (as_list *list)
 
static int as_list_trim (as_list *list, uint32_t index)
 
void as_list_val_destroy (as_val *v)
 
uint32_t as_list_val_hashcode (const as_val *v)
 
char * as_list_val_tostring (const as_val *v)
 

Typedef Documentation

bool(*

Callback function for as_list_foreach(). Called for each element in the list.

Parameters
valueThe value of the current element.
udataThe user-data provided to the as_list_foreach().
Returns
true to continue iterating through the list. false to stop iterating.

Definition at line 48 of file as_list.h.

Function Documentation

static int as_list_append ( as_list list,
as_val value 
)
inlinestatic

Append a value to the list.

Parameters
listThe list.
valueThe value to append to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 964 of file as_list.h.

References as_util_hook.

static int as_list_append_bytes ( as_list list,
as_bytes value 
)
inlinestatic

Append an as_bytes to the list.

Parameters
listThe list.
valueThe value to append to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1034 of file as_list.h.

References as_list::as_list_append().

static int as_list_append_int64 ( as_list list,
int64_t  value 
)
inlinestatic

Append an int64_t to the list.

Parameters
listThe list.
valueThe value to append to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 978 of file as_list.h.

References as_util_hook.

static int as_list_append_integer ( as_list list,
as_integer value 
)
inlinestatic

Append an as_integer to the list.

Parameters
listThe list.
valueThe value to append to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1006 of file as_list.h.

References as_list::as_list_append().

static int as_list_append_list ( as_list list,
as_list value 
)
inlinestatic

Append an as_list to the list.

Parameters
listThe list.
valueThe value to append to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1048 of file as_list.h.

References as_list::as_list_append().

static int as_list_append_map ( as_list list,
as_map_s *  value 
)
inlinestatic

Append an as_map to the list.

Parameters
listThe list.
valueThe value to append to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1062 of file as_list.h.

References as_list::as_list_append().

static int as_list_append_str ( as_list list,
const char *  value 
)
inlinestatic

Append a NULL-terminated string to the list.

Parameters
listThe list.
valueThe value to append to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 992 of file as_list.h.

References as_util_hook.

static int as_list_append_string ( as_list list,
as_string value 
)
inlinestatic

Append an as_string to the list.

Parameters
listThe list.
valueThe value to append to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1020 of file as_list.h.

References as_list::as_list_append().

static int as_list_concat ( as_list list,
const as_list list2 
)
inlinestatic

Append all elements of list2, in order, to list. No new list object is created.

Parameters
listThe list to append to.
list2The list from which to append.
Returns
0 on success. Otherwise an error occurred.

Definition at line 508 of file as_list.h.

References as_util_hook.

as_list * as_list_cons ( as_list list,
bool  free,
void *  data,
const as_list_hooks hooks 
)
private

Utilized by subtypes of as_list to initialize the parent.

Parameters
listThe list to initialize.
freeIf true, then as_list_destroy() will free the list.
dataData for the list.
hooksImplementaton for the list interface.
Returns
On success, the initialized list. Otherwise NULL.
static void as_list_destroy ( as_list list)
inlinestatic

Destroy the list and associated resources.

Parameters
listThe list to destroy.

Definition at line 459 of file as_list.h.

References as_val_destroy.

static as_list * as_list_drop ( const as_list list,
uint32_t  n 
)
inlinestatic

Create a new list containing all elements, except the first n elements, of the list.

Parameters
listThe list to drop elements from.
nThe number of elements to drop.
Returns
On success, a new list containing the remaining elements. Otherwise NULL.

Definition at line 563 of file as_list.h.

References as_util_hook.

static bool as_list_foreach ( const as_list list,
as_list_foreach_callback  callback,
void *  udata 
)
inlinestatic

Call the callback function for each element in the list..

Parameters
listThe list to iterate over.
callbackThe callback function call for each element.
udataUser-data to send to the callback.
Returns
true if iteration completes fully. false if iteration was aborted.

Definition at line 1219 of file as_list.h.

References as_util_hook.

static as_list * as_list_fromval ( as_val v)
inlinestatic

Convert from an as_val.

Definition at line 1269 of file as_list.h.

References AS_LIST, and as_util_fromval.

static as_val * as_list_get ( const as_list list,
uint32_t  i 
)
inlinestatic

Get the value at specified index as an as_val.

Parameters
listThe list to get the value from.
iThe index of the value to get from the list.
Returns
On success, the value at the given index. Otherwise NULL.

Definition at line 595 of file as_list.h.

References as_util_hook.

static as_bytes * as_list_get_bytes ( const as_list list,
uint32_t  i 
)
inlinestatic

Get the value at specified index as an as_val.

Parameters
listThe list to get the value from.
iThe index of the value to get from the list.
Returns
On success, the value at the given index. Otherwise NULL.

Definition at line 665 of file as_list.h.

References as_bytes::as_bytes_fromval(), and as_list::as_list_get().

static int64_t as_list_get_int64 ( const as_list list,
uint32_t  i 
)
inlinestatic

Get the value at specified index as an int64_t.

Parameters
listThe list to get the value from.
iThe index of the value to get from the list.
Returns
On success, the value at the given index. Otherwise NULL.

Definition at line 609 of file as_list.h.

References as_util_hook.

static as_integer * as_list_get_integer ( const as_list list,
uint32_t  i 
)
inlinestatic

Get the value at specified index as an as_integer.

Parameters
listThe list to get the value from.
iThe index of the value to get from the list.
Returns
On success, the value at the given index. Otherwise NULL.

Definition at line 637 of file as_list.h.

References as_integer::as_integer_fromval(), and as_list::as_list_get().

static as_list * as_list_get_list ( const as_list list,
uint32_t  i 
)
inlinestatic

Get the value at specified index as an as_val.

Parameters
listThe list to get the value from.
iThe index of the value to get from the list.
Returns
On success, the value at the given index. Otherwise NULL.

Definition at line 679 of file as_list.h.

References AS_LIST, as_list::as_list_get(), and as_val::type.

static struct as_map_s * as_list_get_map ( const as_list list,
uint32_t  i 
)
static

Get the value at specified index as an as_val.

Parameters
listThe list to get the value from.
iThe index of the value to get from the list.
Returns
On success, the value at the given index. Otherwise NULL.

Definition at line 694 of file as_list.h.

References as_list::as_list_get(), AS_MAP, and as_val::type.

static char * as_list_get_str ( const as_list list,
uint32_t  i 
)
inlinestatic

Get the value at specified index as an NULL terminated string.

Parameters
listThe list to get the value from.
iThe index of the value to get from the list.
Returns
On success, the value at the given index. Otherwise NULL.

Definition at line 623 of file as_list.h.

References as_util_hook.

static as_string * as_list_get_string ( const as_list list,
uint32_t  i 
)
inlinestatic

Get the value at specified index as an as_val.

Parameters
listThe list to get the value from.
iThe index of the value to get from the list.
Returns
On success, the value at the given index. Otherwise NULL.

Definition at line 651 of file as_list.h.

References as_list::as_list_get(), and as_string::as_string_fromval().

static uint32_t as_list_hashcode ( as_list list)
inlinestatic

Get the hashcode value for the list.

Parameters
listThe list.
Returns
The hashcode of the list.

Definition at line 476 of file as_list.h.

References as_util_hook.

static as_val * as_list_head ( const as_list list)
inlinestatic

The first element in the list.

Parameters
listThe list to get the head value from.
Returns
The first value of the list on success. Otherwise NULL.

Definition at line 536 of file as_list.h.

References as_util_hook.

as_list * as_list_init ( as_list list,
void *  data,
const as_list_hooks hooks 
)

Initialize a stack allocated list.

Parameters
listStack allocated list to initialize.
dataData for the list.
hooksImplementaton for the list interface.
Returns
On succes, the initialized list. Otherwise NULL.
static int as_list_insert ( as_list list,
uint32_t  i,
as_val value 
)
inlinestatic

Insert a value at the specified index of the list.

Any elements at and beyond specified index will be shifted so their indexes increase by 1. It's ok to insert beyond the current end of the list.

Parameters
listThe list.
iThe index at which to insert.
valueThe value to insert at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 841 of file as_list.h.

References as_util_hook.

static int as_list_insert_bytes ( as_list list,
uint32_t  i,
as_bytes value 
)
inlinestatic

Insert an as_bytes at specified index as an as_val.

Parameters
listThe list.
iThe index at which to insert.
valueThe value to insert at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 916 of file as_list.h.

References as_list::as_list_insert().

static int as_list_insert_int64 ( as_list list,
uint32_t  i,
int64_t  value 
)
inlinestatic

Insert an int64_t at specified index as an as_val.

Parameters
listThe list.
iThe index at which to insert.
valueThe value to insert at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 856 of file as_list.h.

References as_util_hook.

static int as_list_insert_integer ( as_list list,
uint32_t  i,
as_integer value 
)
inlinestatic

Insert an as_integer at specified index as an as_val.

Parameters
listThe list.
iThe index at which to insert.
valueThe value to insert at the given index.
Returns
0 on success. Otherwise an error ocucrred.

Definition at line 886 of file as_list.h.

References as_list::as_list_insert().

static int as_list_insert_list ( as_list list,
uint32_t  i,
as_list value 
)
inlinestatic

Insert an as_list at specified index as an as_val.

Parameters
listThe list.
iThe index at which to insert.
valueThe value to insert at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 931 of file as_list.h.

References as_list::as_list_insert().

static int as_list_insert_map ( as_list list,
uint32_t  i,
as_map_s *  value 
)
inlinestatic

Insert an as_map at specified index as an as_val.

Parameters
listThe list.
iThe index at which to insert.
valueThe value to insert at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 946 of file as_list.h.

References as_list::as_list_insert().

static int as_list_insert_str ( as_list list,
uint32_t  i,
const char *  value 
)
inlinestatic

Insert a NULL-terminated string at specified index as an as_val.

Parameters
listThe list.
iThe index at which to insert.
valueThe value to insert at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 871 of file as_list.h.

References as_util_hook.

static int as_list_insert_string ( as_list list,
uint32_t  i,
as_string value 
)
inlinestatic

Insert an as_string at specified index as an as_val.

Parameters
listThe list.
iThe index at which to insert.
valueThe value to insert at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 901 of file as_list.h.

References as_list::as_list_insert().

static union as_list_iterator_u * as_list_iterator_init ( as_list_iterator_u *  it,
const as_list list 
)
static

Initializes a stack allocated iterator over the given list.

Parameters
listThe list to iterate.
itThe iterator to initialize.
Returns
On success, the initializes as_iterator. Otherwise NULL.

Definition at line 1247 of file as_list.h.

References as_util_hook.

static union as_list_iterator_u * as_list_iterator_new ( const as_list list)
static

Creates and initializes a new heap allocated iterator over the given list.

Parameters
listThe list to iterate.
Returns
On success, a new as_iterator. Otherwise NULL.

Definition at line 1232 of file as_list.h.

References as_util_hook.

as_list * as_list_new ( void *  data,
const as_list_hooks hooks 
)

Create and initialize a new heap allocated list.

Parameters
dataData for the list.
hooksImplementaton for the list interface.
Returns
On succes, a new list. Otherwise NULL.
static int as_list_prepend ( as_list list,
as_val value 
)
inlinestatic

Prepend a value to the list.

Parameters
listThe list.
valueThe value to prepend to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1080 of file as_list.h.

References as_util_hook.

static int as_list_prepend_bytes ( as_list list,
as_bytes value 
)
inlinestatic

Prepend an as_bytes to the list.

Parameters
listThe list.
valueThe value to prepend to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1150 of file as_list.h.

References as_list::as_list_prepend().

static int as_list_prepend_int64 ( as_list list,
int64_t  value 
)
inlinestatic

Prepend an int64_t value to the list.

Parameters
listThe list.
valueThe value to prepend to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1094 of file as_list.h.

References as_util_hook.

static int as_list_prepend_integer ( as_list list,
as_integer value 
)
inlinestatic

Prepend an as_integer to the list.

Parameters
listThe list.
valueThe value to prepend to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1122 of file as_list.h.

References as_list::as_list_prepend().

static int as_list_prepend_list ( as_list list,
as_list value 
)
inlinestatic

Prepend an as_list to the list.

Parameters
listThe list.
valueThe value to prepend to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1164 of file as_list.h.

References as_list::as_list_prepend().

static int as_list_prepend_map ( as_list list,
as_map_s *  value 
)
inlinestatic

Prepend an as_map to the list.

Parameters
listThe list.
valueThe value to prepend to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1178 of file as_list.h.

References as_list::as_list_prepend().

static int as_list_prepend_str ( as_list list,
const char *  value 
)
inlinestatic

Prepend a NULL-terminated string to the list.

Parameters
listThe list.
valueThe value to prepend to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1108 of file as_list.h.

References as_util_hook.

static int as_list_prepend_string ( as_list list,
as_string value 
)
inlinestatic

Prepend an as_string to the list.

Parameters
listThe list.
valueThe value to prepend to the list.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1136 of file as_list.h.

References as_list::as_list_prepend().

static int as_list_remove ( as_list list,
uint32_t  i 
)
inlinestatic

Remove element at specified index.

Any elements beyond specified index will be shifted so their indexes decrease by 1. The element at specified index will be destroyed.

Parameters
listThe list.
indexThe index of the element to remove.
Returns
0 on success. Otherwise an error occurred.

Definition at line 1199 of file as_list.h.

References as_util_hook.

static int as_list_set ( as_list list,
uint32_t  i,
as_val value 
)
inlinestatic

Set the value at specified index as an as_val.

Parameters
listThe list.
iThe index of the value to set in the list.
valueThe value to set at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 714 of file as_list.h.

References as_util_hook.

static int as_list_set_bytes ( as_list list,
uint32_t  i,
as_bytes value 
)
inlinestatic

Set an as_bytes at specified index as an as_val.

Parameters
listThe list.
iThe index of the value to set in the list.
valueThe value to set at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 789 of file as_list.h.

References as_list::as_list_set().

static int as_list_set_int64 ( as_list list,
uint32_t  i,
int64_t  value 
)
inlinestatic

Set an int64_t at specified index as an as_val.

Parameters
listThe list.
iThe index of the value to set in the list.
valueThe value to set at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 729 of file as_list.h.

References as_util_hook.

static int as_list_set_integer ( as_list list,
uint32_t  i,
as_integer value 
)
inlinestatic

Set an as_integer at specified index as an as_val.

Parameters
listThe list.
iThe index of the value to set in the list.
valueThe value to set at the given index.
Returns
0 on success. Otherwise an error ocucrred.

Definition at line 759 of file as_list.h.

References as_list::as_list_set().

static int as_list_set_list ( as_list list,
uint32_t  i,
as_list value 
)
inlinestatic

Set an as_list at specified index as an as_val.

Parameters
listThe list.
iThe index of the value to set in the list.
valueThe value to set at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 804 of file as_list.h.

References as_list::as_list_set().

static int as_list_set_map ( as_list list,
uint32_t  i,
as_map_s *  value 
)
inlinestatic

Set an as_map at specified index as an as_val.

Parameters
listThe list.
iThe index of the value to set in the list.
valueThe value to set at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 819 of file as_list.h.

References as_list::as_list_set().

static int as_list_set_str ( as_list list,
uint32_t  i,
const char *  value 
)
inlinestatic

Set a NULL-terminated string at specified index as an as_val.

Parameters
listThe list.
iThe index of the value to set in the list.
valueThe value to set at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 744 of file as_list.h.

References as_util_hook.

static int as_list_set_string ( as_list list,
uint32_t  i,
as_string value 
)
inlinestatic

Set an as_string at specified index as an as_val.

Parameters
listThe list.
iThe index of the value to set in the list.
valueThe value to set at the given index.
Returns
0 on success. Otherwise an error occurred.

Definition at line 774 of file as_list.h.

References as_list::as_list_set().

static uint32_t as_list_size ( as_list list)
inlinestatic

Number of elements in the list.

Parameters
listThe list.
Returns
The size of the list.

Definition at line 489 of file as_list.h.

References as_util_hook.

static as_list * as_list_tail ( const as_list list)
inlinestatic

All elements after the first element in the list.

Parameters
listThe list to get the tail from.
Returns
On success, the tail of the list. Otherwise NULL.

Definition at line 549 of file as_list.h.

References as_util_hook.

static as_list * as_list_take ( const as_list list,
uint32_t  n 
)
inlinestatic

Creates a new list containing the first n elements of the list.

Parameters
listThe list to drop elements from.
nThe number of elements to take.
Returns
On success, a new list containing the selected elements. Otherwise NULL.

Definition at line 577 of file as_list.h.

References as_util_hook.

static as_val * as_list_toval ( as_list list)
inlinestatic

Convert to an as_val.

Definition at line 1260 of file as_list.h.

static int as_list_trim ( as_list list,
uint32_t  index 
)
inlinestatic

Delete (and destroy) all elements at and beyond specified index. Capacity is not reduced.

Parameters
listThe list to trim.
indexThe index from which to trim.
Returns
0 on success. Otherwise an error occurred.

Definition at line 523 of file as_list.h.

References as_util_hook.

void as_list_val_destroy ( as_val v)
private

Internal helper function for destroying an as_val.

uint32_t as_list_val_hashcode ( const as_val v)
private

Internal helper function for getting the hashcode of an as_val.

char* as_list_val_tostring ( const as_val v)
private

Internal helper function for getting the string representation of an as_val.