Xbase Class Library  2.0.0
xbexcept.h
Go to the documentation of this file.
1 /* $Id: xbexcept.h,v 1.6 2000/11/10 19:04:17 dbryson Exp $
2 
3  Xbase project source code
4 
5  This file contains definitions for xbase exceptions.
6 
7  Copyright (C) 1997 StarTech, Gary A. Kunkel
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 
23  Contact:
24 
25  Mail:
26 
27  Technology Associates, Inc.
28  XBase Project
29  1455 Deming Way #11
30  Sparks, NV 89434
31  USA
32 
33  Email:
34 
35  xbase@techass.com
36 
37  See our website at:
38 
39  xdb.sourceforge.net
40 */
41 
42 #ifndef __XBEXCEPT_H__
43 #define __XBEXCEPT_H__
44 
45 #ifdef __GNUG__
46 #pragma interface
47 #endif
48 
49 #ifdef __WIN32__
50 #include <xbase/xbconfigw32.h>
51 #else
52 #include <xbase/xbconfig.h>
53 #endif
54 
55 #include <xbase/xtypes.h>
56 
60 const char *xbStrError(xbShort err);
61 
62 #ifndef HAVE_EXCEPTIONS
63 #define xb_error(code) { return code;}
64 #define xb_io_error(code,name) { return code;}
65 #define xb_open_error(name) { return XB_OPEN_ERROR;}
66 #define xb_memory_error { return XB_NO_MEMORY;}
67 #define xb_eof_error { return XB_EOF;}
68 #else
69 
70 #ifdef HAVE_EXCEPTION
71 
72 #include <exception>
73 #elif HAVE_G___EXCEPTION_H
74 #include <g++/exception.h>
75 #elif
76 #error "Exceptions are unsupported on your system."
77 #endif
78 
79 #ifdef __BORLANDC__
80 #define XB_THROW throw ()
81 using std::exception;
82 #else
83 #define XB_THROW
84 #endif
85 
87 
90 /* FIXME: class exception is member of <stdexcept.h> -- willy */
91 class XBDLLEXPORT xbException : public exception {
92 public:
93  xbException (int err);
94  virtual ~xbException () XB_THROW;
95  virtual const char* what() const XB_THROW;
96  virtual const char *error();
97  int getErr();
98 private:
99  int err;
100 };
101 
102 #define xb_error(code) {throw xbException(code);return (code);}
103 
105 
108 class XBDLLEXPORT xbIOException : public xbException {
109 public:
110  xbIOException (int err);
111  xbIOException (int err, const char *n);
112  virtual ~xbIOException () XB_THROW;
113  virtual const char* what() const XB_THROW;
114  const char *_errno() const;
115  const char *name;
116 protected:
117  int m_errno;
118 };
119 
120 #define xb_io_error(code, name) {throw xbIOException(code,name);return (code);}
121 
123 
126 class XBDLLEXPORT xbOpenException : public xbIOException {
127 public:
128  xbOpenException ();
129  xbOpenException (const char *n);
130  virtual ~xbOpenException () XB_THROW;
131  virtual const char* what() const XB_THROW;
132 };
133 
134 #define xb_open_error(name) { throw xbOpenException(name); return 0;}
135 
137 
140 class XBDLLEXPORT xbOutOfMemoryException : public xbException {
141 public:
142  xbOutOfMemoryException ();
143  virtual ~xbOutOfMemoryException () XB_THROW;
144  virtual const char* what() const XB_THROW;
145 };
146 
147 #define xb_memory_error {throw xbOutOfMemoryException();return 0;}
148 
150 
153 class XBDLLEXPORT xbEoFException : public xbIOException {
154 public:
155  xbEoFException ();
156  virtual ~xbEoFException () XB_THROW;
157  virtual const char* what() const XB_THROW;
158 };
159 
160 #define xb_eof_error {throw xbEoFException();return 0;}
161 
162 #endif
163 
164 #endif // __XBEXCEPT_H__
#define XBDLLEXPORT
Definition: xbase.h:101
short int xbShort
xbShort type
Definition: xtypes.h:65
const char * xbStrError(xbShort err)
Short description.
Definition: xbexcept.cpp:66