AG_Tbl * AG_TblNew (Uint nBuckets, Uint flags)
void AG_TblInit (AG_Tbl *tbl, Uint nBuckets, Uint flags)
void AG_TblDestroy (AG_Tbl *tbl)
AG_Variable * AG_TblLookup (AG_Tbl *tbl, const char *key)
int AG_TblLookupPointer (AG_Tbl *tbl, const char *key, void **p)
int AG_TblExists (AG_Tbl *tbl, const char *key)
int AG_TblInsert (AG_Tbl *tbl, const char *key, const AG_Variable *V)
int AG_TblInsertPointer (AG_Tbl *tbl, const char *key, void *p)
int AG_TblDelete (AG_Tbl *tbl, const char *key)
AG_TBL_FOREACH (AG_Variable *V, int i, int j, AG_Tbl *tbl)
|
The
AG_TblNew() function allocates and initializes a new, empty
AG_Tbl. AG_TblInit() initializes an existing table structure.
The following
flags options are accepted:
| AG_TBL_DUPLICATES | Allow duplicate keys in the database.
Insert calls for duplicate keys will if this option is not set.
|
AG_TblDestroy() frees the resources allocated by a table (the table structure itself is not
freed).
AG_TblLookup() searches the table for an entry of the given name and returns a pointer to it.
On failure, it returns NULL.
AG_TblExists() returns 1 if there is a table entry matching the giving key.
AG_TblInsert() inserts an entry in the table, using the specified key.
The contents of the variable are duplicated.
On failure, the function returns -1 and sets an error message.
AG_TblDelete() removes the specified table entry by name.
If there is no match, it returns -1 and sets an error message.
The
AG_TBL_FOREACH() macro iterates
V over every entry of table
tbl, using variables
i and
j as iterators.
Example usage:
AG_Tbl *tbl;
AG_Variable *V;
int i, j;
AG_TBL_FOREACH(V, i,j, tbl) {
printf("Item: %s\\n", V->name);
}
|