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

include/om/omerror.h

Go to the documentation of this file.
00001 
00004 /* ----START-LICENCE----
00005  * Copyright 1999,2000,2001 BrightStation PLC
00006  * Copyright 2002 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 OM_HGUARD_OMERROR_H
00026 #define OM_HGUARD_OMERROR_H
00027 
00028 #include <string>
00029 
00030 #include "om/omtypes.h"
00031 
00032 class OmErrorHandler;
00033 
00035 class OmError {
00036     friend class OmErrorHandler;
00037     private:
00039         std::string msg;
00040 
00042         std::string context;
00043 
00045         std::string type;
00046 
00048         int errno_value;
00049 
00051         bool has_been_handled;
00052 
00054         void operator=(const OmError &copyme);
00055     protected:
00059         OmError(const std::string &msg_,
00060                 const std::string &context_,
00061                 const std::string &type_,
00062                 int errno_value_);
00063 
00064         OmError(const OmError &copyme)
00065                 : msg(copyme.msg),
00066                   context(copyme.context),
00067                   type(copyme.type),
00068                   errno_value(copyme.errno_value),
00069                   has_been_handled(copyme.has_been_handled) {}
00070     public:
00074         std::string get_msg() const
00075         {
00076             return msg;
00077         }
00078 
00080         std::string get_type() const
00081         {
00082             return type;
00083         }
00084 
00086         std::string get_context() const
00087         {
00088             return context;
00089         }
00090 
00092         int get_errno() const
00093         {
00094             return errno_value;
00095         }
00096 
00098         // FIXME: no longer pure virtual as that stops us throwing OmError
00099         // objects
00100         virtual ~OmError();
00101 };
00102 
00103 inline OmError::~OmError() {}
00104 
00105 #define DEFINE_ERROR_BASECLASS(a, b) \
00106 class a : public b { \
00107     protected: \
00108  \
00109         a(const std::string &msg_, \
00110           const std::string &context_, \
00111           const std::string &type_, \
00112           int errno_value_) : b(msg_, context_, type_, errno_value_) {}; \
00113 }
00114 
00115 #define DEFINE_ERROR_CLASS(a, b) \
00116 class a : public b { \
00117     public: \
00118  \
00119         a(const std::string &msg_, \
00120           const std::string &context_ = "", \
00121           int errno_value_ = 0) : b(msg_, context_, #a, errno_value_) {}; \
00122  \
00123         a(const std::string &msg_, \
00124           int errno_value_) : b(msg_, "", #a, errno_value_) {}; \
00125     protected: \
00126  \
00127         a(const std::string &msg_, \
00128           const std::string &context_, \
00129           const std::string &type_, \
00130           int errno_value_) : b(msg_, context_, type_, errno_value_) {}; \
00131 }
00132 
00133 #include "om/omerrortypes.h"
00134 
00135 #undef DEFINE_ERROR_BASECLASS
00136 #undef DEFINE_ERROR_CLASS
00137 
00138 #endif /* OM_HGUARD_OMERROR_H */

Documentation for Xapian (version 0.6.3).
Generated on 14 Dec 2002 by Doxygen 1.2.15.