|
Xbase Class Library 2.0.0
|
00001 /* $Id: xbexcept.h,v 1.6 2000/11/10 19:04:17 dbryson Exp $ 00002 00003 Xbase project source code 00004 00005 This file contains definitions for xbase exceptions. 00006 00007 Copyright (C) 1997 StarTech, 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 00037 See our website at: 00038 00039 xdb.sourceforge.net 00040 */ 00041 00042 #ifndef __XBEXCEPT_H__ 00043 #define __XBEXCEPT_H__ 00044 00045 #ifdef __GNUG__ 00046 #pragma interface 00047 #endif 00048 00049 #ifdef __WIN32__ 00050 #include <xbase/xbconfigw32.h> 00051 #else 00052 #include <xbase/xbconfig.h> 00053 #endif 00054 00055 #include <xbase/xtypes.h> 00056 00060 const char *xbStrError(xbShort err); 00061 00062 #ifndef HAVE_EXCEPTIONS 00063 #define xb_error(code) { return code;} 00064 #define xb_io_error(code,name) { return code;} 00065 #define xb_open_error(name) { return XB_OPEN_ERROR;} 00066 #define xb_memory_error { return XB_NO_MEMORY;} 00067 #define xb_eof_error { return XB_EOF;} 00068 #else 00069 00070 #ifdef HAVE_EXCEPTION 00071 00072 #include <exception> 00073 #elif HAVE_G___EXCEPTION_H 00074 #include <g++/exception.h> 00075 #elif 00076 #error "Exceptions are unsupported on your system." 00077 #endif 00078 00079 #ifdef __BORLANDC__ 00080 #define XB_THROW throw () 00081 using std::exception; 00082 #else 00083 #define XB_THROW 00084 #endif 00085 00087 00090 /* FIXME: class exception is member of <stdexcept.h> -- willy */ 00091 class XBDLLEXPORT xbException : public exception { 00092 public: 00093 xbException (int err); 00094 virtual ~xbException () XB_THROW; 00095 virtual const char* what() const XB_THROW; 00096 virtual const char *error(); 00097 int getErr(); 00098 private: 00099 int err; 00100 }; 00101 00102 #define xb_error(code) {throw xbException(code);return (code);} 00103 00105 00108 class XBDLLEXPORT xbIOException : public xbException { 00109 public: 00110 xbIOException (int err); 00111 xbIOException (int err, const char *n); 00112 virtual ~xbIOException () XB_THROW; 00113 virtual const char* what() const XB_THROW; 00114 const char *_errno() const; 00115 const char *name; 00116 protected: 00117 int m_errno; 00118 }; 00119 00120 #define xb_io_error(code, name) {throw xbIOException(code,name);return (code);} 00121 00123 00126 class XBDLLEXPORT xbOpenException : public xbIOException { 00127 public: 00128 xbOpenException (); 00129 xbOpenException (const char *n); 00130 virtual ~xbOpenException () XB_THROW; 00131 virtual const char* what() const XB_THROW; 00132 }; 00133 00134 #define xb_open_error(name) { throw xbOpenException(name); return 0;} 00135 00137 00140 class XBDLLEXPORT xbOutOfMemoryException : public xbException { 00141 public: 00142 xbOutOfMemoryException (); 00143 virtual ~xbOutOfMemoryException () XB_THROW; 00144 virtual const char* what() const XB_THROW; 00145 }; 00146 00147 #define xb_memory_error {throw xbOutOfMemoryException();return 0;} 00148 00150 00153 class XBDLLEXPORT xbEoFException : public xbIOException { 00154 public: 00155 xbEoFException (); 00156 virtual ~xbEoFException () XB_THROW; 00157 virtual const char* what() const XB_THROW; 00158 }; 00159 00160 #define xb_eof_error {throw xbEoFException();return 0;} 00161 00162 #endif 00163 00164 #endif // __XBEXCEPT_H__
1.7.3