memo_word

Word related structures and functions. More...


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_databasememo_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_wordmemo_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.


Detailed Description

Word related structures and functions.

Typedef Documentation

A node in a translations' list.

If next is NULL the given node is the last translation.


Function Documentation

int memo_word_add_translation ( memo_word w1,
memo_word w2 
)

Inserts a new translation to the database.

Adds a (w1, w2) pair to the translations table.

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

int memo_word_check_translation ( memo_word w1,
memo_word w2 
)

Checks whether the given translation exists in the database.

Returns:
0 if the translation in correct, 1 if it is not, negative values in case of errors.

int memo_word_copy ( memo_word dest,
memo_word src 
)

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.

Parameters:
dest the destination (has to be allocated using memo_word_new).
src the source word.
Returns:
0 in case of success, negative values in case of errors.

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.

Finds a (w1, w2) pair in the translations table and removes it.

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

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.

Returns:
the database's address.

int memo_word_get_key ( memo_word word  ) 

Returns word's database unique key.

Returns:
word's key.

int memo_word_get_negative_answers ( memo_word word  ) 

Fetches negative answers count for a given word.

Returns:
negative answers count.

int memo_word_get_positive_answers ( memo_word word  ) 

Fetches positive answers count for a given word.

Returns:
positive answers count.

int memo_word_get_translations ( memo_word word,
memo_word ***  translations 
)

Returns word's translations.

Parameters:
word the word.
translations a pointer to an array of pointers to memo_word structures.
Returns:
non-negative integer equal to the number of the given word's translations count or negative values in case of errors.
Example of usage:
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.

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.

Returns:
a pointer to a new word, NULL in case of errors.

int memo_word_reload ( memo_word word  ) 

Reloads the given word from the database.

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

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.

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

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.

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

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.

Parameters:
word a word.
value a string to set the word's value to.
Returns:
0 in case of success, negative values in case of errors.

int memo_word_update ( memo_word word  ) 

Updates given word's row in the database.

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


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