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_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. | |
memo_word * | memo_database_find_word (memo_database *db, int key) |
Fetches a word with a given key from the database. | |
memo_word * | memo_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_database * | memo_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. |
typedef struct memo_database memo_database |
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_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.
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. |
memo_word* memo_database_find_word | ( | memo_database * | db, | |
int | key | |||
) |
Fetches a word with a given key from the database.
db | the database to search. | |
key | the key we're looking for. |
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.
db | the database to search. | |
value | the string we're looking for. |
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.
int memo_database_init | ( | memo_database * | db | ) |
Initialise the database.
Create the structure of tables, unless they already exist. Internal use only.
memo_word** memo_database_load_words_from_database_data | ( | memo_database * | db, | |
memo_database_data * | data | |||
) |
memo_database* memo_database_open | ( | const char * | filename | ) |
Prepares a memo_database.
filename | A filename of a file with a 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.
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.
db | a database to take the words from. | |
count | number of words to fetch. |