suggest.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef SUGGEST_H
00009 #define SUGGEST_H
00010
00011
00012 #include <sstream>
00013 #include <stdexcept>
00014 #include <string>
00015 #include <vector>
00016 #include <iostream>
00017
00018 #include <aspell.h>
00019
00023 namespace Speller {
00024 namespace Aspell {
00031 class Suggest {
00032 private:
00034 AspellConfig* fconfig;
00036 AspellSpeller* fspeller;
00038 std::string flang;
00040 std::string fjargon;
00042 std::string fencoding;
00043
00052 void checkError() throw( std::runtime_error );
00061 void checkConfigError() throw( std::runtime_error );
00073 void init(const std::string& lang, const std::string& jargon,
00074 const std::string& encoding)
00075 throw( std::invalid_argument, std::runtime_error );
00085 void printWordList(const AspellWordList* wlist,
00086 char delim='\n') throw(std::invalid_argument);
00095 void setConfig() throw( std::invalid_argument );
00105 void storeWordList(const AspellWordList* wlist,
00106 std::vector<std::string>& replacement)
00107 throw( std::invalid_argument );
00108
00109 public:
00113 static const char* kDICT_DELIM;
00117 static const char* kEMPTY;
00119 static const char* kDEF_LANG;
00121 static const char* kDEF_JARGON;
00123 static const char* kDEF_ENCODING;
00124
00125
00126
00127
00139 Suggest(const std::string& lang=kDEF_LANG,
00140 const std::string& jargon=kDEF_JARGON,
00141 const std::string& encoding=kDEF_ENCODING)
00142 throw( std::invalid_argument, std::runtime_error );
00153 Suggest(const AspellDictInfo* dinfo,
00154 const std::string& encoding=kDEF_ENCODING)
00155 throw( std::invalid_argument, std::runtime_error );
00164 void addPersonalList(const std::string& word)
00165 throw( std::runtime_error );
00173 bool checkWord(const std::string& word);
00182 bool checkWord(const std::string& word,
00183 std::vector<std::string>& replacement,
00184 bool always=true) throw( std::invalid_argument );
00193 void clearSessionList() throw( std::runtime_error );
00201 std::string getConfigOpt(const std::string& opt);
00210 void getConfigOpt(const std::string& opt,
00211 std::vector<std::string>& vals);
00220 void ignoreWord(const std::string& word)
00221 throw( std::runtime_error );
00229 void listDicts(std::vector<AspellDictInfo>& vals);
00237 void listDicts(std::vector<std::string>& vals);
00246 void printMainList() throw( std::invalid_argument );
00255 void printPersonalList() throw( std::invalid_argument );
00264 void printSessionList() throw( std::invalid_argument );
00274 bool printSuggestions(const std::string& word, bool always=true)
00275 throw( std::invalid_argument );
00285 void resetConfig()
00286 throw( std::invalid_argument, std::runtime_error );
00298 void resetConfig(const std::string& lang,
00299 const std::string& jargon,
00300 const std::string& encoding=kDEF_ENCODING)
00301 throw( std::invalid_argument, std::runtime_error );
00310 void saveLists() throw( std::runtime_error );
00320 void setConfigOpt(const std::string& opt, const std::string& val)
00321 throw( std::invalid_argument );
00330 void StoreMainList(std::vector<std::string>& replacement)
00331 throw( std::invalid_argument );
00340 void StorePersonalList(std::vector<std::string>& replacement)
00341 throw( std::invalid_argument );
00350 void StoreSessionList(std::vector<std::string>& replacement)
00351 throw( std::invalid_argument );
00352 };
00353 }
00354 }
00355 #endif // #ifndef SUGGEST_H
00356