include/xapian/error.h

Go to the documentation of this file.
00001 
00004 /* ----START-LICENCE----
00005  * Copyright 1999,2000,2001 BrightStation PLC
00006  * Copyright 2002,2003,2004 Olly Betts
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License as
00010  * published by the Free Software Foundation; either version 2 of the
00011  * License, or (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
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00021  * USA
00022  * -----END-LICENCE-----
00023  */
00024 
00025 #ifndef XAPIAN_INCLUDED_ERROR_H
00026 #define XAPIAN_INCLUDED_ERROR_H
00027 
00028 #include <string>
00029 
00030 namespace Xapian {
00031 
00032 class ErrorHandler;
00033 
00038 class Error {
00039     friend class ErrorHandler;
00040     private:
00042         std::string msg;
00043 
00045         std::string context;
00046 
00048         std::string type;
00049 
00051         int errno_value;
00052 
00054         bool has_been_handled;
00055 
00057         void operator=(const Error &copyme);
00058 
00059     protected:
00063         Error(const std::string &msg_, const std::string &context_,
00064               const std::string &type_, int errno_value_);
00065 
00066         Error(const Error &o) : msg(o.msg), context(o.context), type(o.type),
00067             errno_value(o.errno_value), has_been_handled(o.has_been_handled) {}
00068 
00069     public:
00073         std::string get_msg() const
00074         {
00075             return msg;
00076         }
00077 
00079         std::string get_type() const
00080         {
00081             return type;
00082         }
00083 
00085         std::string get_context() const
00086         {
00087             return context;
00088         }
00089 
00091         int get_errno() const
00092         {
00093             return errno_value;
00094         }
00095 
00097         virtual ~Error() { }
00098 };
00099 
00101 #define XAPIAN_DEFINE_ERROR_BASECLASS(a, b) \
00102 class a : public b { \
00103     protected: \
00104  \
00105         a(const std::string &msg_, \
00106           const std::string &context_, \
00107           const std::string &type_, \
00108           int errno_value_) : b(msg_, context_, type_, errno_value_) {} \
00109 }
00110 
00112 #define XAPIAN_DEFINE_ERROR_CLASS(a, b) \
00113 class a : public b { \
00114     public: \
00115  \
00116         a(const std::string &msg_, \
00117           const std::string &context_ = "", \
00118           int errno_value_ = 0) : b(msg_, context_, #a, errno_value_) {} \
00119  \
00120         a(const std::string &msg_, \
00121           int errno_value_) : b(msg_, "", #a, errno_value_) {} \
00122     protected: \
00123  \
00124         a(const std::string &msg_, \
00125           const std::string &context_, \
00126           const std::string &type_, \
00127           int errno_value_) : b(msg_, context_, type_, errno_value_) {} \
00128 }
00129 
00130 #include <xapian/errortypes.h>
00131 
00132 #undef XAPIAN_DEFINE_ERROR_BASECLASS
00133 #undef XAPIAN_DEFINE_ERROR_CLASS
00134 
00135 }
00136 
00137 #endif /* XAPIAN_INCLUDED_ERROR_H */

Documentation for Xapian (version 0.9.6).
Generated on 15 May 2006 by Doxygen 1.4.6.