Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes

XAP_Dictionary Class Reference

#include <xap_Dictionary.h>

List of all members.

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

Constructor & Destructor Documentation

XAP_Dictionary::XAP_Dictionary ( const char *  szFilename  ) 

References m_bDirty, m_fp, m_szFilename, and UT_ASSERT.

XAP_Dictionary::~XAP_Dictionary (  ) 

Member Function Documentation

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.

Referenced by load(), and save().

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]
UT_uint32 XAP_Dictionary::_writeBytes ( const UT_Byte pBytes,
UT_uint32  length 
) [protected]

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  ) 
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
bool XAP_Dictionary::load ( void   ) 
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
UT_Vector * pVecSuggestions this a vector of suggestions. The returner is responsible for deleting these words.

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().

Member Data Documentation

bool XAP_Dictionary::m_bDirty [protected]

Referenced by addWord(), load(), save(), and XAP_Dictionary().

FILE* XAP_Dictionary::m_fp [private]
char* XAP_Dictionary::m_szFilename [protected]

The documentation for this class was generated from the following files: