• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

xap_Dictionary.h

Go to the documentation of this file.
00001 /* AbiSource Application Framework
00002  * Copyright (C) 1998,1999 AbiSource, Inc.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301 USA.
00018  */
00019 
00020 
00021 #ifndef XAP_DICTIONARY_H
00022 #define XAP_DICTIONARY_H
00023 
00024 #include <stdio.h>
00025 
00026 /* pre-emptive dismissal; ut_types.h is needed by just about everything,
00027  * so even if it's commented out in-file that's still a lot of work for
00028  * the preprocessor to do...
00029  */
00030 #ifndef UT_TYPES_H
00031 #include "ut_types.h"
00032 #endif
00033 #include "ut_hash.h"
00034 
00035 /*
00036     A simple custom dictionary class, which allows the user to add words
00037     which aren't in the standard dictionary.  The contents are stored as
00038     UTF-8 plaintext, with one word per line.
00039 */
00040 class ABI_EXPORT XAP_Dictionary
00041 {
00042 public:
00043     XAP_Dictionary(const char * szFilename);
00044     ~XAP_Dictionary();
00045 
00046     const char *        getShortName(void) const;
00047 
00048     bool                load(void);
00049     bool                save(void);
00050     UT_uint32                       countCommonChars(UT_UCSChar * pszNeedle, UT_UCSChar *pszHaystack);
00051     void                            suggestWord(UT_GenericVector<UT_UCSChar *> * pVecSuggestions, const UT_UCSChar * pWord, UT_uint32 len);
00052     bool                            addWord(const char * pWord);
00053     bool                addWord(const UT_UCSChar * pWord, UT_uint32 len);
00054     bool                isWord(const UT_UCSChar * pWord, UT_uint32 len) const;
00055 
00056 protected:
00057     bool                _openFile(const char * mode);
00058     UT_uint32           _writeBytes(const UT_Byte * pBytes, UT_uint32 length);
00059     bool                _writeBytes(const UT_Byte * sz);
00060     bool                _closeFile(void);
00061     void                _abortFile(void);
00062 
00063     bool                _parseUTF8(void);
00064     void                _outputUTF8(const UT_UCSChar * data, UT_uint32 length);
00065 
00066     char *      m_szFilename;
00067 
00068     bool                m_bDirty;
00069     UT_GenericStringMap<UT_UCSChar *>       m_hashWords;
00070 
00071 private:
00072     FILE *              m_fp;
00073 };
00074 
00075 
00076 #endif /* XAP_DICTIONARY_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1