liboggz  1.1.1
Typedefs | Functions
oggz_table.h File Reference

A lookup table. More...

Go to the source code of this file.

Typedefs

typedef void OggzTable
 A table of key-value pairs.
 

Functions

OggzTableoggz_table_new (void)
 Instantiate a new OggzTable. More...
 
void oggz_table_delete (OggzTable *table)
 Delete an OggzTable. More...
 
void * oggz_table_insert (OggzTable *table, long key, void *data)
 Insert an element into a table. More...
 
int oggz_table_remove (OggzTable *table, long key)
 Remove the element of an OggzTable indexed by a given key. More...
 
void * oggz_table_lookup (OggzTable *table, long key)
 Retrieve the element of an OggzTable indexed by a given key. More...
 
int oggz_table_size (OggzTable *table)
 Query the number of elements in an OggzTable. More...
 
void * oggz_table_nth (OggzTable *table, int n, long *key)
 Retrieve the nth element of an OggzTable, and optionally its key. More...
 

Detailed Description

A lookup table.

OggzTable is provided for convenience to allow the storage of serialno-specific data.

Function Documentation

void oggz_table_delete ( OggzTable table)

Delete an OggzTable.

Parameters
tableAn OggzTable
void* oggz_table_insert ( OggzTable table,
long  key,
void *  data 
)

Insert an element into a table.

If a previous value existed for this key, it is overwritten with the new data element.

Parameters
tableAn OggzTable
keyKey to access this data element
dataThe new element to add
Return values
dataIf the element was successfully added
NULLIf adding the element failed due to a realloc() error
void* oggz_table_lookup ( OggzTable table,
long  key 
)

Retrieve the element of an OggzTable indexed by a given key.

Parameters
tableAn OggzTable
keya key
Returns
The element indexed by key
Return values
NULLtable is undefined, or no element is indexed by key
OggzTable* oggz_table_new ( void  )

Instantiate a new OggzTable.

Returns
A new OggzTable
Return values
NULLCould not allocate memory for table
void* oggz_table_nth ( OggzTable table,
int  n,
long *  key 
)

Retrieve the nth element of an OggzTable, and optionally its key.

Parameters
tableAn OggzTable
nAn index into the table
keyReturn pointer for key corresponding to nth data element of table. Ignored if NULL.
Returns
The nth data element of table
Return values
NULLtable is undefined, or n is out of range
int oggz_table_remove ( OggzTable table,
long  key 
)

Remove the element of an OggzTable indexed by a given key.

Parameters
tableAn OggzTable
keya key
Return values
0Success
-1Not found
int oggz_table_size ( OggzTable table)

Query the number of elements in an OggzTable.

Parameters
tableAn OggzTable
Returns
the number of elements in table