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

xbexcept.h

Go to the documentation of this file.
00001 /* $Id: xbexcept.h,v 1.7 2003/08/16 19:59:39 gkunkel Exp $ 00002 00003 Xbase project source code 00004 00005 This file contains definitions for xbase exceptions. 00006 00007 Copyright (C) 1997 Gary A. Kunkel 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU Lesser General Public 00011 License as published by the Free Software Foundation; either 00012 version 2.1 of the License, or (at your option) any later version. 00013 00014 This library is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public 00020 License along with this library; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00022 00023 Contact: 00024 00025 Mail: 00026 00027 Technology Associates, Inc. 00028 XBase Project 00029 1455 Deming Way #11 00030 Sparks, NV 89434 00031 USA 00032 00033 Email: 00034 00035 xbase@techass.com 00036 xdb-devel@lits.sourceforge.net 00037 xdb-users@lists.sourceforge.net 00038 00039 See our website at: 00040 00041 xdb.sourceforge.net 00042 */ 00043 00044 #ifndef __XBEXCEPT_H__ 00045 #define __XBEXCEPT_H__ 00046 00047 #ifdef __GNUG__ 00048 #pragma interface 00049 #endif 00050 00051 #ifdef __WIN32__ 00052 #include <xbase/xbconfigw32.h> 00053 #else 00054 #include <xbase/xbconfig.h> 00055 #endif 00056 00057 #include <xbase/xtypes.h> 00058 00062 const char *xbStrError(xbShort err); 00063 00064 #ifndef HAVE_EXCEPTIONS 00065 #define xb_error(code) { return code;} 00066 #define xb_io_error(code,name) { return code;} 00067 #define xb_open_error(name) { return XB_OPEN_ERROR;} 00068 #define xb_memory_error { return XB_NO_MEMORY;} 00069 #define xb_eof_error { return XB_EOF;} 00070 #else 00071 00072 #ifdef HAVE_EXCEPTION 00073 00074 #include <exception> 00075 #elif HAVE_G___EXCEPTION_H 00076 #include <g++/exception.h> 00077 #else 00078 #error "Exceptions are unsupported on your system." 00079 #endif 00080 00081 #ifdef __BORLANDC__ 00082 #define XB_THROW throw () 00083 using std::exception; 00084 #else 00085 #define XB_THROW 00086 #endif 00087 00089 00092 /* FIXME: class exception is member of <stdexcept.h> -- willy */ 00093 class XBDLLEXPORT xbException : public exception { 00094 public: 00095 xbException (int err); 00096 virtual ~xbException () XB_THROW; 00097 virtual const char* what() const XB_THROW; 00098 virtual const char *error(); 00099 int getErr(); 00100 private: 00101 int err; 00102 }; 00103 00104 #define xb_error(code) {throw xbException(code);return (code);} 00105 00107 00110 class XBDLLEXPORT xbIOException : public xbException { 00111 public: 00112 xbIOException (int err); 00113 xbIOException (int err, const char *n); 00114 virtual ~xbIOException () XB_THROW; 00115 virtual const char* what() const XB_THROW; 00116 const char *_errno() const; 00117 const char *name; 00118 protected: 00119 int m_errno; 00120 }; 00121 00122 #define xb_io_error(code, name) {throw xbIOException(code,name);return (code);} 00123 00125 00128 class XBDLLEXPORT xbOpenException : public xbIOException { 00129 public: 00130 xbOpenException (); 00131 xbOpenException (const char *n); 00132 virtual ~xbOpenException () XB_THROW; 00133 virtual const char* what() const XB_THROW; 00134 }; 00135 00136 #define xb_open_error(name) { throw xbOpenException(name); return 0;} 00137 00139 00142 class XBDLLEXPORT xbOutOfMemoryException : public xbException { 00143 public: 00144 xbOutOfMemoryException (); 00145 virtual ~xbOutOfMemoryException () XB_THROW; 00146 virtual const char* what() const XB_THROW; 00147 }; 00148 00149 #define xb_memory_error {throw xbOutOfMemoryException();return 0;} 00150 00152 00155 class XBDLLEXPORT xbEoFException : public xbIOException { 00156 public: 00157 xbEoFException (); 00158 virtual ~xbEoFException () XB_THROW; 00159 virtual const char* what() const XB_THROW; 00160 }; 00161 00162 #define xb_eof_error {throw xbEoFException();return 0;} 00163 00164 #endif 00165 00166 #endif // __XBEXCEPT_H__

Generated on Sat Sep 11 04:01:10 2004 for Xbase Class Library by doxygen 1.3.7