#include <xap_Dictionary.h>
Public Member Functions | |
XAP_Dictionary (const char *szFilename) | |
~XAP_Dictionary () | |
const char * | getShortName (void) const |
bool | load (void) |
bool | save (void) |
UT_uint32 | countCommonChars (UT_UCSChar *pszNeedle, UT_UCSChar *pszHaystack) |
void | suggestWord (UT_GenericVector< UT_UCSChar * > *pVecSuggestions, const UT_UCSChar *pWord, UT_uint32 len) |
bool | addWord (const char *pWord) |
bool | addWord (const UT_UCSChar *pWord, UT_uint32 len) |
bool | isWord (const UT_UCSChar *pWord, UT_uint32 len) const |
Protected Member Functions | |
bool | _openFile (const char *mode) |
UT_uint32 | _writeBytes (const UT_Byte *pBytes, UT_uint32 length) |
bool | _writeBytes (const UT_Byte *sz) |
bool | _closeFile (void) |
void | _abortFile (void) |
bool | _parseUTF8 (void) |
void | _outputUTF8 (const UT_UCSChar *data, UT_uint32 length) |
Protected Attributes | |
char * | m_szFilename |
bool | m_bDirty |
UT_GenericStringMap< UT_UCSChar * > | m_hashWords |
Private Attributes | |
FILE * | m_fp |
XAP_Dictionary::XAP_Dictionary | ( | const char * | szFilename | ) |
References m_bDirty, m_fp, m_szFilename, and UT_ASSERT.
XAP_Dictionary::~XAP_Dictionary | ( | ) |
void XAP_Dictionary::_abortFile | ( | void | ) | [protected] |
References _closeFile().
Referenced by load().
bool XAP_Dictionary::_closeFile | ( | void | ) | [protected] |
References m_fp.
Referenced by _abortFile(), load(), save(), and ~XAP_Dictionary().
bool XAP_Dictionary::_openFile | ( | const char * | mode | ) | [protected] |
References m_fp, m_szFilename, and UT_ASSERT.
void XAP_Dictionary::_outputUTF8 | ( | const UT_UCSChar * | data, | |
UT_uint32 | length | |||
) | [protected] |
References _writeBytes(), UT_String::c_str(), gchar, and UT_String::size().
Referenced by save().
bool XAP_Dictionary::_parseUTF8 | ( | void | ) | [protected] |
References addWord(), gchar, UT_GrowBuf::getLength(), UT_GrowBuf::getPointer(), UT_GrowBuf::ins(), m_fp, UT_GrowBuf::truncate(), and X_ReturnIfFail.
Referenced by load().
References m_fp, and UT_ASSERT.
Referenced by _outputUTF8(), _writeBytes(), and save().
bool XAP_Dictionary::_writeBytes | ( | const UT_Byte * | sz | ) | [protected] |
References _writeBytes(), m_fp, and UT_ASSERT.
bool XAP_Dictionary::addWord | ( | const char * | pWord | ) |
References FREEP, UT_calloc(), and UT_UCS4_strcpy_char().
Referenced by _parseUTF8(), XAP_App::addWordToDict(), and load().
bool XAP_Dictionary::addWord | ( | const UT_UCSChar * | pWord, | |
UT_uint32 | len | |||
) |
UT_uint32 XAP_Dictionary::countCommonChars | ( | UT_UCSChar * | pszHaystack, | |
UT_UCSChar * | pszNeedle | |||
) |
This method counts the number of common characters in pszNeedle found in pszHaystack. Every time character in pszNeedle is found in pszHaystack the score is incremented by 1.
References UT_UCS4_strlen(), and UT_UCS4_strstr().
Referenced by suggestWord().
const char * XAP_Dictionary::getShortName | ( | void | ) | const |
bool XAP_Dictionary::isWord | ( | const UT_UCSChar * | pWord, | |
UT_uint32 | len | |||
) | const |
References UT_GenericStringMap< T >::contains(), FREEP, m_hashWords, UT_calloc(), UT_DEBUGMSG, and xxx_UT_DEBUGMSG.
Referenced by XAP_App::isWordInDict().
bool XAP_Dictionary::load | ( | void | ) |
References _abortFile(), _closeFile(), _openFile(), _parseUTF8(), addWord(), m_bDirty, m_hashWords, UT_GenericStringMap< T >::size(), and UT_ASSERT.
Referenced by XAP_App::initialize().
bool XAP_Dictionary::save | ( | void | ) |
void XAP_Dictionary::suggestWord | ( | UT_GenericVector< UT_UCSChar * > * | pVecSuggestions, | |
const UT_UCSChar * | pWord, | |||
UT_uint32 | len | |||
) |
Returns true if the word given is found in the users custom dictionary.
const | UT_UCSChar * pWord the word to look for suggestion for | |
UT_uint32 | len the length of the word |
References UT_GenericVector< T >::addItem(), countCommonChars(), DELETEP, UT_GenericStringMap< T >::enumerate(), FREEP, UT_GenericVector< T >::getItemCount(), UT_GenericVector< T >::getNthItem(), m_hashWords, UT_ASSERT, UT_calloc(), UT_UCS4_cloneString(), and UT_UCS4_strlen().
Referenced by XAP_App::suggestWord().
bool XAP_Dictionary::m_bDirty [protected] |
Referenced by addWord(), load(), save(), and XAP_Dictionary().
FILE* XAP_Dictionary::m_fp [private] |
Referenced by _closeFile(), _openFile(), _parseUTF8(), _writeBytes(), XAP_Dictionary(), and ~XAP_Dictionary().
UT_GenericStringMap<UT_UCSChar *> XAP_Dictionary::m_hashWords [protected] |
Referenced by addWord(), isWord(), load(), save(), suggestWord(), and ~XAP_Dictionary().
char* XAP_Dictionary::m_szFilename [protected] |
Referenced by _openFile(), XAP_Dictionary(), and ~XAP_Dictionary().