Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / dti_cc / cc_exceptions.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $TOG: cc_exceptions.h /main/5 1998/04/17 11:44:44 mgreess $ */
24
25 #ifndef _cc_exception_h
26 #define _cc_exception_h 1
27
28 #include <fstream.h>
29 #include "Exceptions.hh"
30
31 #define END_TRY end_try 
32
33 #include <X11/Xosdefs.h>
34 #include <errno.h>
35 #ifdef X_NOT_STDC_ENV
36 extern int errno;
37 #endif
38
39 #if defined(linux)
40 #define CASTCCEXCEPT (ccException*)
41 #define CASTCCSEXCEPT (ccStringException*)
42 #define CASTCCBEXCEPT (ccBoundaryException*)
43 #else
44 #define CASTCCEXCEPT
45 #define CASTCCSEXCEPT
46 #define CASTCCBEXCEPT
47 #endif
48
49 class ccException : public Exception
50 {
51 public:
52    DECLARE_EXCEPTION(ccException, Exception);
53
54    virtual ~ccException() {};
55
56    virtual ostream& asciiOut(ostream&);
57
58    friend ostream& operator <<(ostream& out, ccException& e) {
59       return e.asciiOut(out);
60    }
61 };
62
63
64 class ccStringException : public ccException
65 {
66 protected:
67    char* msg;
68
69 public:
70    DECLARE_EXCEPTION(ccStringException, ccException);
71
72    ccStringException(char* m) : msg(m) {};
73    ~ccStringException() {};
74
75    virtual ostream& asciiOut(ostream&);
76 };
77
78 class ccBoundaryException : public ccException
79 {
80
81 protected:
82    int low;
83    int high;
84    int index;
85
86 public:
87    DECLARE_EXCEPTION(ccBoundaryException, ccException);
88
89    ccBoundaryException(int l, int h, int i) : 
90      low(l), high(h), index(i) {};
91    ~ccBoundaryException() {};
92
93    virtual ostream& asciiOut(ostream&);
94 };
95
96
97 #endif