1 /** 2 * Yudit Unicode Editor Source File 3 * 4 * GNU Copyright (C) 1997-2006 Gaspar Sinai <gaspar@yudit.org> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License, version 2, 8 * dated June 1991. See file COPYYING for details. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 */ 19 20 #ifndef SHunspellPattern_h 21 #define SHunspellPattern_h 22 23 #include "stoolkit/syntax/SPattern.h" 24 #include "stoolkit/SString.h" 25 #include "stoolkit/SStringVector.h" 26 #include "stoolkit/SEncoder.h" 27 28 extern "C" 29 { 30 typedef struct _HunspellFunctions_ 31 { 32 void* (*create)(const char * affpath, const char * dpath); 33 int (*spell)(void* hunspell, const char *word); 34 int (*destroy)(void* hunspell); 35 char* (*get_dic_encoding)(void* hunspell); 36 } HunspellFunctions; 37 } 38 39 /** 40 * A regular expression pattern. 41 * @author Gaspar Sinai 42 * @version 2007-11-27 43 */ 44 class SHunspellPattern : public SPattern 45 { 46 public: 47 SHunspellPattern (const SString& name, const SStringVector& path); 48 virtual ~SHunspellPattern (); 49 // This method updates matchBegin and matchEnd (exclusive) 50 // variables in case of a match, in case of no match, this 51 // will not be touched. Action will contain that action string. 52 virtual bool checkMatch (); 53 static SString getFolderFor (const SString& name, const SStringVector& path); 54 static SString getMissingFile (const SString& name, const SStringVector& path); 55 private: 56 static SString loadLibrary (const SStringVector& path); 57 bool isSeparator (SS_UCS4 chr) const; 58 bool isNumber (SS_UCS4 chr) const; 59 bool isOther (SS_UCS4 chr) const; 60 bool isJapanese (SS_UCS4 chr) const; 61 SString name; 62 SString dicFile; 63 SString affFile; 64 void* hunspell; 65 HunspellFunctions functions; 66 SEncoder* entryEncoder; 67 }; 68 69 #endif /* SHunspellPattern_h */ 70