GME
13
|
Arrays are used to store data which is referenced sequentially or as a stack. Functions are provided to push and pop individual elements as well as to operate on the entire array.
Tables are used to store data which can be referenced by key. Limited capabilities are provided for tables with multiple elements which share a key; while key lookup will return only a single element, iteration is available. Additionally, a table can be compressed to resolve duplicates.
Both arrays and tables may store string or binary data; some features, such as concatenation or merging of elements, work only for string data.
#define APR_ARRAY_IDX | ( | ary, | |
i, | |||
type | |||
) | (((type *)(ary)->elts)[i]) |
A helper macro for accessing a member of an APR array.
ary | the array |
i | the index into the array to return |
type | the type of the objects stored in the array |
Definition at line 141 of file apr_tables.h.
#define APR_ARRAY_PUSH | ( | ary, | |
type | |||
) | (*((type *)apr_array_push(ary))) |
A helper macro for pushing elements into an APR array.
ary | the array |
type | the type of the objects stored in the array |
Definition at line 150 of file apr_tables.h.
#define APR_OVERLAP_TABLES_MERGE (1) |
flag for overlap to use apr_table_mergen
Definition at line 426 of file apr_tables.h.
#define APR_OVERLAP_TABLES_SET (0) |
flag for overlap to use apr_table_setn
Definition at line 424 of file apr_tables.h.
typedef struct apr_array_header_t apr_array_header_t |
Definition at line 59 of file apr_tables.h.
typedef int( apr_table_do_callback_fn_t)(void *rec, const char *key, const char *value) |
Declaration prototype for the iterator callback function of apr_table_do() and apr_table_vdo().
rec | The data passed as the first argument to apr_table_[v]do() |
key | The key from this iteration of the table |
value | The value from this iteration of the table |
Definition at line 372 of file apr_tables.h.
typedef struct apr_table_entry_t apr_table_entry_t |
The (opaque) structure for string-content tables.
Definition at line 78 of file apr_tables.h.
typedef struct apr_table_t apr_table_t |
the table abstract data type
Definition at line 56 of file apr_tables.h.
APR_DECLARE | ( | const apr_array_header_t * | ) | const |
Get the elements from a table.
t | The table |
APR_DECLARE | ( | int | ) | const |
Determine if the table is empty (either NULL or having no elements).
t | The table to check |
Determine if the array is empty (either NULL or having no elements).
a | The array to check |
Iterate over a table running the provided function once for every element in the table. The
vp | varargs parameter must be a list of zero or more (char *) keys followed by a NULL pointer. If zero keys are given, the |
comp | function will be invoked for every element in the table. Otherwise, the function is invoked only for those elements matching the keys specified. |
If an invocation of the
comp | function returns zero, iteration will continue using the next specified key, if any. |
comp | The function to run |
rec | The data to pass as the first argument to the function |
t | The table to iterate over |
vp | List of zero or more (char *) keys followed by NULL |
Create an array.
p | The pool to allocate the memory out of |
nelts | the number of elements in the initial array |
elt_size | The size of each element in the array. |
Copy the entire array.
p | The pool to allocate the copy of the array out of |
arr | The array to copy |
Copy the headers of the array, and arrange for the elements to be copied if and only if the code subsequently does a push or arraycat.
p | The pool to allocate the copy of the array out of |
arr | The array to copy |
Append one array to the end of another, creating a new array in the process.
p | The pool to allocate the new array out of |
first | The array to put first in the new array. |
second | The array to put second in the new array. |
APR_DECLARE | ( | void * | ) |
Add a new element to an array (as a first-in, last-out stack).
arr | The array to add an element to. |
Remove an element from an array (as a first-in, last-out stack).
arr | The array to remove an element from. |
Look up the value associated with a key in a hash table.
ht | The hash table |
key | Pointer to the key |
klen | Length of the key. Can be APR_HASH_KEY_STRING to use the string length. |
Allocate a block of memory from a pool
p | The pool to allocate from |
size | The amount of memory to allocate |
Debug version of apr_palloc
p | See: apr_palloc |
size | See: apr_palloc |
file_line | Where the function is called from. This is usually APR_POOL__FILE_LINE__. |
Debug version of apr_pcalloc
p | See: apr_pcalloc |
size | See: apr_pcalloc |
file_line | Where the function is called from. This is usually APR_POOL__FILE_LINE__. |
Duplicate a block of memory.
p | The pool to allocate from |
m | The memory to duplicate |
n | The number of bytes to duplicate |
APR_DECLARE | ( | void | ) |
Remove all elements from an array.
arr | The array to remove all elements from. |
Concatenate two arrays together.
dst | The destination array, and the one to go first in the combined array |
src | The source array to add to the destination array |
Delete all of the elements from a table.
t | The table to clear |
Add a key/value pair to a table. If another element already exists with the same key, this will overwrite the old data.
t | The table to add the data to. |
key | The key to use (case does not matter) |
val | The value to add |
Add a key/value pair to a table. If another element already exists with the same key, this will overwrite the old data.
t | The table to add the data to. |
key | The key to use (case does not matter) |
val | The value to add |
Remove data from the table.
t | The table to remove data from |
key | The key of the data being removed (case does not matter) |
Add data to a table by merging the value with data that has already been stored. The merging is done by concatenating the two values, separated by the string ", ".
t | The table to search for the data |
key | The key to merge data for (case does not matter) |
val | The data to add |
Add data to a table by merging the value with data that has already been stored. The merging is done by concatenating the two values, separated by the string ", ".
t | The table to search for the data |
key | The key to merge data for (case does not matter) |
val | The data to add |
Add data to a table, regardless of whether there is another element with the same key.
t | The table to add to |
key | The key to use |
val | The value to add. |
Add data to a table, regardless of whether there is another element with the same key.
t | The table to add to |
key | The key to use |
val | The value to add. |
For each element in table b, either use setn or mergen to add the data to table a. Which method is used is determined by the flags passed in.
a | The table to add the data to. |
b | The table to iterate over, adding its data to table a |
flags | How to add the table to table a. One of: APR_OVERLAP_TABLES_SET Use apr_table_setn APR_OVERLAP_TABLES_MERGE Use apr_table_mergen |
apr_array_header_t *barr = apr_table_elts(b); apr_table_entry_t *belt = (apr_table_entry_t *)barr->elts; int i;
for (i = 0; i < barr->nelts; ++i) { if (flags & APR_OVERLAP_TABLES_MERGE) { apr_table_mergen(a, belt[i].key, belt[i].val); } else { apr_table_setn(a, belt[i].key, belt[i].val); } }
Except that it is more efficient (less space and cpu-time) especially when b has many elements.
Notice the assumptions on the keys and values in b -- they must be in an ancestor of a's pool. In practice b and a are usually from the same pool.
Eliminate redundant entries in a table by either overwriting or merging duplicates.
t | Table. |
flags | APR_OVERLAP_TABLES_MERGE to merge, or APR_OVERLAP_TABLES_SET to overwrite |
APR_DECLARE | ( | char * | ) |
Generate a new string from the apr_pool_t containing the concatenated sequence of substrings referenced as elements within the array. The string will be empty if all substrings are empty or null, or if there are no elements in the array. If sep is non-NUL, it will be inserted between elements as a separator.
p | The pool to allocate the string out of |
arr | The array to generate the string from |
sep | The separator to use |
APR_DECLARE | ( | apr_table_t * | ) |
Make a new table.
p | The pool to allocate the pool out of |
nelts | The number of elements in the initial table. |
Create a new table and copy another table into it.
p | The pool to allocate the new table out of |
t | The table to copy |
Create a new table whose contents are deep copied from the given table. A deep copy operation copies all fields, and makes copies of dynamically allocated memory pointed to by the fields.
p | The pool to allocate the new table out of |
t | The table to clone |
Merge two tables into one new table.
p | The pool to use for the new table |
overlay | The first table to put in the new table |
base | The table to add at the end of the new table |
APR_DECLARE | ( | const char * | ) | const |
Get the value associated with a given key from the table. After this call, the data is still in the table.
t | The table to search for the key |
key | The key to search for (case does not matter) |
Iterate over a table running the provided function once for every element in the table. The varargs array must be a list of zero or more (char *) keys followed by a NULL pointer. If zero keys are given, the
comp | function will be invoked for every element in the table. Otherwise, the function is invoked only for those elements matching the keys specified. |
If an invocation of the
comp | function returns zero, iteration will continue using the next specified key, if any. |
comp | The function to run |
rec | The data to pass as the first argument to the function |
t | The table to iterate over |
... | A varargs array of zero or more (char *) keys followed by NULL |
const apr_array_header_t * arr |
Definition at line 187 of file apr_tables.h.
const apr_table_t* b |
Definition at line 466 of file apr_tables.h.
const apr_table_t const apr_table_t* base |
Definition at line 359 of file apr_tables.h.
Definition at line 122 of file apr_tables.h.
const apr_array_header_t* first |
Definition at line 207 of file apr_tables.h.
unsigned flags |
Definition at line 466 of file apr_tables.h.
const char* key |
Definition at line 268 of file apr_tables.h.
Definition at line 122 of file apr_tables.h.
const apr_table_t* overlay |
Definition at line 359 of file apr_tables.h.
void const apr_table_t void* rec |
Definition at line 395 of file apr_tables.h.
const apr_array_header_t const apr_array_header_t* second |
Definition at line 207 of file apr_tables.h.
const apr_array_header_t const char sep |
Definition at line 222 of file apr_tables.h.
const apr_array_header_t* src |
Definition at line 175 of file apr_tables.h.
void const apr_table_t void const apr_table_t* t |
Definition at line 242 of file apr_tables.h.
const char const char* val |
Definition at line 279 of file apr_tables.h.
void const apr_table_t void const apr_table_t va_list vp |
Definition at line 421 of file apr_tables.h.