memo_database

Database related structures and functions. More...


Data Structures

struct  memo_database
struct  memo_database_data
 Used to retrieve data from the database. More...

Typedefs

typedef struct memo_database memo_database

Enumerations

enum  memo_database_data_types { INTEGER, STRING }

Functions

int memo_database_close (memo_database *db)
 Closes the database.
void memo_database_data_free (memo_database_data *data)
 Frees a memo_database_data structure.
memo_database_datamemo_database_data_init ()
 Prepares a new memo_database_data structure.
int memo_database_execute (memo_database *db, const char *query, memo_database_data *ret)
 Executes a given SQL query.
memo_wordmemo_database_find_word (memo_database *db, int key)
 Fetches a word with a given key from the database.
memo_wordmemo_database_find_word_by_value (memo_database *db, const char *value)
 Fetches a word with a given value from the database.
unsigned long memo_database_get_last_change (memo_database *db)
 Returns the ID of the last change to the database.
int memo_database_init (memo_database *db)
 Initialise the database.
memo_word ** memo_database_load_words_from_database_data (memo_database *db, memo_database_data *data)
 Creates a memo_word structure filled with the provided data.
memo_databasememo_database_open (const char *filename)
 Prepares a memo_database.
void memo_database_update_last_change (void *data, int action, char const *dbname, char const *rowname, sqlite3_int64 rowid)
 A callback updating memo_database::last_change.
memo_word ** memo_database_words_to_test (memo_database *db, int count)
 Chooses a set of words to be sent to the user.


Detailed Description

Database related structures and functions.

Typedef Documentation

typedef struct memo_database memo_database


Enumeration Type Documentation

Enumerator:
INTEGER 
STRING 


Function Documentation

int memo_database_close ( memo_database db  ) 

Closes the database.

Returns:
0.

void memo_database_data_free ( memo_database_data data  ) 

Frees a memo_database_data structure.

memo_database_data* memo_database_data_init (  ) 

Prepares a new memo_database_data structure.

int memo_database_execute ( memo_database db,
const char *  query,
memo_database_data ret 
)

Executes a given SQL query.

Parameters:
db the database to which the query will be sent.
query the query.
ret pointer to a structure where the results will be stored. If it's NULL the results will not be saved.
Returns:
0 in case of success, negative values in case of errors.

memo_word* memo_database_find_word ( memo_database db,
int  key 
)

Fetches a word with a given key from the database.

Parameters:
db the database to search.
key the key we're looking for.
Returns:
pointer to the found word or NULL if it wasn't found or errors have occured.

memo_word* memo_database_find_word_by_value ( memo_database db,
const char *  value 
)

Fetches a word with a given value from the database.

Parameters:
db the database to search.
value the string we're looking for.
Returns:
pointer to the found word or NULL if it wasn't found or errors have occured.

unsigned long memo_database_get_last_change ( memo_database db  ) 

Returns the ID of the last change to the database.

Returns:
value of memo_database::last_change field.

int memo_database_init ( memo_database db  ) 

Initialise the database.

Create the structure of tables, unless they already exist. Internal use only.

Returns:
0 in case of success, negative values in case of errors.

memo_word** memo_database_load_words_from_database_data ( memo_database db,
memo_database_data data 
)

Creates a memo_word structure filled with the provided data.

Parameters:
db a database the word is in.
data data fetched from db to be inserted into the structure.
Returns:
a new memo_word structure.

memo_database* memo_database_open ( const char *  filename  ) 

Prepares a memo_database.

Parameters:
filename A filename of a file with a database.
Returns:
0 in case of success, negative values in case of errors.

void memo_database_update_last_change ( void *  data,
int  action,
char const *  dbname,
char const *  rowname,
sqlite3_int64  rowid 
)

A callback updating memo_database::last_change.

memo_word** memo_database_words_to_test ( memo_database db,
int  count 
)

Chooses a set of words to be sent to the user.

Currently it chooses words of highest negative to positive answers ratio. It is hoped that a better algorithm will be implemented in foreseeable future.

The result array has to be freed.

Parameters:
db a database to take the words from.
count number of words to fetch.
Returns:
an array of pointers to chosen words.


Generated on Sun Feb 22 01:45:40 2009 for memo by  doxygen 1.5.7.1