Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

include/om/omerror.h

00001 /* omerror.h
00002  *
00003  * ----START-LICENCE----
00004  * Copyright 1999,2000,2001 BrightStation PLC
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License as
00008  * published by the Free Software Foundation; either version 2 of the
00009  * License, or (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00019  * USA
00020  * -----END-LICENCE-----
00021  */
00022 
00023 #ifndef OM_HGUARD_OMERROR_H
00024 #define OM_HGUARD_OMERROR_H
00025 
00026 #include <string>
00027 
00028 #include "om/omtypes.h"
00029 
00030 class OmErrorHandler;
00031 
00033 class OmError {
00034     friend class OmErrorHandler;
00035     private:
00037         std::string msg;
00038 
00040         std::string context;
00041 
00043         std::string type;
00044 
00046         int errno_value;
00047 
00049         bool has_been_handled;
00050 
00052         void operator=(const OmError &copyme);
00053     protected:
00057         OmError(const std::string &msg_,
00058                 const std::string &context_,
00059                 const std::string &type_,
00060                 int errno_value_);
00061 
00062         OmError(const OmError &copyme)
00063                 : msg(copyme.msg),
00064                   context(copyme.context),
00065                   type(copyme.type),
00066                   errno_value(copyme.errno_value),
00067                   has_been_handled(copyme.has_been_handled) {}
00068     public:
00072         std::string get_msg() const
00073         {
00074             return msg;
00075         }
00076 
00078         std::string get_type() const
00079         {
00080             return type;
00081         }
00082 
00084         std::string get_context() const
00085         {
00086             return context;
00087         }
00088 
00090         int get_errno() const
00091         {
00092             return errno_value;
00093         }
00094 
00096         // FIXME: no longer pure virtual as that stops us throwing OmError
00097         // objects
00098         virtual ~OmError();
00099 };
00100 
00101 inline OmError::~OmError() {}
00102 
00103 #define DEFINE_ERROR_BASECLASS(a, b) \
00104 class a : public b { \
00105     protected: \
00106  \
00107         a(const std::string &msg_, \
00108           const std::string &context_, \
00109           const std::string &type_, \
00110           int errno_value_) : b(msg_, context_, type_, errno_value_) {}; \
00111 }
00112 
00113 #define DEFINE_ERROR_CLASS(a, b) \
00114 class a : public b { \
00115     public: \
00116  \
00117         a(const std::string &msg_, \
00118           const std::string &context_ = "", \
00119           int errno_value_ = 0) : b(msg_, context_, #a, errno_value_) {}; \
00120  \
00121         a(const std::string &msg_, \
00122           int errno_value_) : b(msg_, "", #a, errno_value_) {}; \
00123     protected: \
00124  \
00125         a(const std::string &msg_, \
00126           const std::string &context_, \
00127           const std::string &type_, \
00128           int errno_value_) : b(msg_, context_, type_, errno_value_) {}; \
00129 }
00130 
00131 #include "om/omerrortypes.h"
00132 
00133 #undef DEFINE_ERROR_BASECLASS
00134 #undef DEFINE_ERROR_CLASS
00135 
00136 #endif /* OM_HGUARD_OMERROR_H */

Documentation for Xapian (version 0.5.5).
Generated on 4 Dec 2002 by Doxygen 1.2.15.