CQDB Reader API


Detailed Description

The CQDB reader API provides a read access to the database whose memory image is loaded on a memory block.

The memory-passing interface has several advantages. Firstly, one can choose an efficient way for their application to load a database image to a memory block, e.g., to read the whole image from a file, to use the Memory Mapped File (mmap) API, etc. Secondaly, one can design the file format freely only if the memory block for a database is extracted from the file.

The most fundamental operation on the CQDB reader API is forward lookup through the use of cqdb_to_id() function, which retrieves integer identifiers from strings. Reverse lookup (retrieving strings from integer identifiers) with cqdb_to_string() function is not supported if the database has been created with CQDB_ONEWAY flag.


Typedefs

typedef tag_cqdb cqdb_t
 Typedef of a CQDB reader.

Functions

cqdb_tcqdb_reader (void *buffer, size_t size)
 Open a new CQDB reader on a memory block.
void cqdb_delete (cqdb_t *db)
 Delete the CQDB reader.
int cqdb_to_id (cqdb_t *db, const char *str)
 Retrieve the identifier associated with a string.
const char * cqdb_to_string (cqdb_t *db, int id)
 Retrieve the string associated with an identifier.
int cqdb_num (cqdb_t *db)
 Get the number of associations in the database.


Function Documentation

void cqdb_delete ( cqdb_t db  ) 

Delete the CQDB reader.

This function frees the work area allocated by cqdb_reader() function.

Parameters:
db The pointer to the cqdb_t instance.

int cqdb_num ( cqdb_t db  ) 

Get the number of associations in the database.

This function returns the number of associations in the database.

Parameters:
db The pointer to the cqdb_t instance.
Return values:
int The number of string/identifier associations.

cqdb_t* cqdb_reader ( void *  buffer,
size_t  size 
)

Open a new CQDB reader on a memory block.

This function initializes a database on a memory block and returns the pointer to a cqdb_t instance to access the database.

Parameters:
buffer The pointer to the memory block.
size The size of the memory block.
Return values:
cqdb_t* The pointer to the cqdb_t instance.

int cqdb_to_id ( cqdb_t db,
const char *  str 
)

Retrieve the identifier associated with a string.

This function returns the identifier associated with a string.

Parameters:
db The pointer to the cqdb_t instance.
str The pointer to a string.
Return values:
int The non-negative identifier if successful, negative status code otherwise.

const char* cqdb_to_string ( cqdb_t db,
int  id 
)

Retrieve the string associated with an identifier.

This function returns the string associated with an identifier.

Parameters:
db The pointer to the cqdb_t instance.
id The id.
Return values:
const char* The pointer to the string associated with the identifier if successful; otherwise NULL.


Copyright (c) 2002-2007 by Naoaki Okazaki
Sat Dec 1 18:09:35 2007