Data Structures | |
struct | _memo_translation |
A node in a translations' list. More... | |
struct | memo_word |
Represents a word. More... | |
Typedefs | |
typedef struct _memo_translation | memo_translation |
A node in a translations' list. | |
Functions | |
int | memo_word_add_translation (memo_word *w1, memo_word *w2) |
Inserts a new translation to the database. | |
int | memo_word_check_translation (memo_word *w1, memo_word *w2) |
Checks whether the given translation exists in the database. | |
int | memo_word_copy (memo_word *dest, memo_word *src) |
Copies a word. | |
int | memo_word_delete (memo_word *word) |
Deletes a word from the database. | |
int | memo_word_delete_translation (memo_word *w1, memo_word *w2) |
Deletes an existing translation from the database. | |
void | memo_word_free (memo_word *word) |
Frees the memory occupied by a given memo_word . | |
memo_database * | memo_word_get_db (memo_word *word) |
Returns a pointer to a database the word's in. | |
int | memo_word_get_key (memo_word *word) |
Returns word's database unique key. | |
int | memo_word_get_negative_answers (memo_word *word) |
Fetches negative answers count for a given word. | |
int | memo_word_get_positive_answers (memo_word *word) |
Fetches positive answers count for a given word. | |
int | memo_word_get_translations (memo_word *word, memo_word ***translations) |
Returns word's translations. | |
const char * | memo_word_get_value (memo_word *word) |
Returns word's value. | |
void | memo_word_inc_negative_answers (memo_word *word) |
Increments words negative answers count by one. | |
void | memo_word_inc_positive_answers (memo_word *word) |
Increments words positive answers count by one. | |
memo_word * | memo_word_new (memo_database *db) |
Create a new, empty word. | |
int | memo_word_reload (memo_word *word) |
Reloads the given word from the database. | |
int | memo_word_reload_by_value (memo_word *word) |
Reloads the given word from the database using it's value. | |
int | memo_word_save (memo_word *word) |
Inserts the given word to the database. | |
void | memo_word_set_negative_answers (memo_word *word, unsigned value) |
Set's words negative answers count to the given value. | |
void | memo_word_set_positive_answers (memo_word *word, unsigned value) |
Set's words positive answers count to the given value. | |
int | memo_word_set_value (memo_word *word, const char *value) |
Sets word's value. | |
int | memo_word_update (memo_word *word) |
Updates given word's row in the database. |
typedef struct _memo_translation memo_translation |
A node in a translations' list.
If next is NULL
the given node is the last translation.
Inserts a new translation to the database.
Adds a (w1
, w2
) pair to the translations table.
Checks whether the given translation exists in the database.
Copies a word.
The result is just a copy of the memo_word structure. The word cannot be copied inside of the database due to value's uniqueness.
dest | the destination (has to be allocated using memo_word_new). | |
src | the source word. |
int memo_word_delete | ( | memo_word * | word | ) |
Deletes a word from the database.
Deletes an existing translation from the database.
Finds a (w1
, w2
) pair in the translations table and removes it.
memo_database* memo_word_get_db | ( | memo_word * | word | ) |
Returns a pointer to a database the word's in.
int memo_word_get_key | ( | memo_word * | word | ) |
Returns word's database unique key.
int memo_word_get_negative_answers | ( | memo_word * | word | ) |
Fetches negative answers count for a given word.
int memo_word_get_positive_answers | ( | memo_word * | word | ) |
Fetches positive answers count for a given word.
Returns word's translations.
word | the word. | |
translations | a pointer to an array of pointers to memo_word structures. |
memo_word *words[3], **translations; int count, i; for (i = 0; i < 3; ++i) { words[i] = memo_word_new(db); memo_word_set_value(words[i], random_string[i]); memo_word_save(words[i]); } memo_word_add_translation(words[0], words[1]); memo_word_add_translation(words[1], words[2]); count = memo_word_get_translations(words[1], &translations); /* count is equal to 2 and translations contains pointers to copies * of words[0] and words[2]. */
const char* memo_word_get_value | ( | memo_word * | word | ) |
Returns word's value.
void memo_word_inc_negative_answers | ( | memo_word * | word | ) |
Increments words negative answers count by one.
void memo_word_inc_positive_answers | ( | memo_word * | word | ) |
Increments words positive answers count by one.
memo_word* memo_word_new | ( | memo_database * | db | ) |
Create a new, empty word.
NULL
in case of errors. int memo_word_reload | ( | memo_word * | word | ) |
Reloads the given word from the database.
int memo_word_reload_by_value | ( | memo_word * | word | ) |
Reloads the given word from the database using it's value.
Dedicated to internal usage. Used in memo_word_save to get word's id after saving it.
int memo_word_save | ( | memo_word * | word | ) |
Inserts the given word to the database.
This function is not updating an already inserted word - if such behaviour is necessary use memo_word_update.
void memo_word_set_negative_answers | ( | memo_word * | word, | |
unsigned | value | |||
) |
Set's words negative answers count to the given value.
void memo_word_set_positive_answers | ( | memo_word * | word, | |
unsigned | value | |||
) |
Set's words positive answers count to the given value.
int memo_word_set_value | ( | memo_word * | word, | |
const char * | value | |||
) |
Sets word's value.
word | a word. | |
value | a string to set the word's value to. |
int memo_word_update | ( | memo_word * | word | ) |
Updates given word's row in the database.