presage
0.8.7
|
00001 00002 /****************************************************** 00003 * Presage, an extensible predictive text entry system 00004 * --------------------------------------------------- 00005 * 00006 * Copyright (C) 2008 Matteo Vescovi <matteo.vescovi@yahoo.co.uk> 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License along 00019 with this program; if not, write to the Free Software Foundation, Inc., 00020 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00021 * 00022 **********(*)*/ 00023 00024 00025 #ifndef PRESAGE_EXCEPTION 00026 #define PRESAGE_EXCEPTION 00027 00028 #ifdef __cplusplus 00029 extern "C" { 00030 #endif 00031 00032 typedef enum 00033 { 00034 PRESAGE_OK = 0, /* successful result */ 00035 PRESAGE_ERROR, /* generic/unknown presage error */ 00036 PRESAGE_TOKEN_PREFIX_MISMATCH_ERROR, 00037 PRESAGE_SMOOTHED_NGRAM_PREDICTOR_LEARN_ERROR, 00038 PRESAGE_CONFIG_VARIABLE_ERROR, 00039 PRESAGE_INVALID_CALLBACK_ERROR, 00040 PRESAGE_INVALID_SUGGESTION_ERROR, 00041 PRESAGE_INIT_PREDICTOR_ERROR, 00042 PRESAGE_SQLITE_OPEN_DATABASE_ERROR, 00043 PRESAGE_SQLITE_EXECUTE_SQL_ERROR 00044 } presage_error_code_t; 00045 00046 #ifdef __cplusplus 00047 } 00048 #endif 00049 00050 00051 #ifdef __cplusplus 00052 #ifndef _MSC_VER 00053 00054 #include <exception> 00055 #include <string> 00056 00067 class PresageException : public std::exception { 00068 public: 00069 PresageException(presage_error_code_t code, const std::string& msg) throw() 00070 : m_details (msg), 00071 m_code (code) 00072 { 00073 // intentionally empty 00074 } 00075 00076 virtual ~PresageException() throw() 00077 { 00078 // intentionally empty 00079 } 00080 00081 virtual const char* what() const throw() 00082 { 00083 return m_details.c_str(); 00084 } 00085 00086 virtual const presage_error_code_t code() const throw() 00087 { 00088 return m_code; 00089 } 00090 00091 private: 00092 std::string m_details; 00093 presage_error_code_t m_code; 00094 00095 }; 00096 00097 #endif /* _MSC_VER */ 00098 #endif /* __cplusplus */ 00099 00100 #endif /* PRESAGE_EXCEPTION */