aboutsummaryrefslogtreecommitdiff
path: root/src/stable/exceptionbase.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable/exceptionbase.h')
-rw-r--r--src/stable/exceptionbase.h304
1 files changed, 152 insertions, 152 deletions
diff --git a/src/stable/exceptionbase.h b/src/stable/exceptionbase.h
index 9e6c72d..8f651b7 100644
--- a/src/stable/exceptionbase.h
+++ b/src/stable/exceptionbase.h
@@ -18,173 +18,173 @@
18 18
19namespace Bu 19namespace Bu
20{ 20{
21 /** 21 /**
22 * A generalized Exception base class. This is nice for making general and 22 * A generalized Exception base class. This is nice for making general and
23 * flexible child classes that can create new error code classes. 23 * flexible child classes that can create new error code classes.
24 * 24 *
25 * In order to create your own exception class use these two lines. 25 * In order to create your own exception class use these two lines.
26 * 26 *
27 * in your header: subExceptionDecl( NewClassName ); 27 * in your header: subExceptionDecl( NewClassName );
28 * 28 *
29 * in your source: subExcpetienDef( NewClassName ); 29 * in your source: subExcpetienDef( NewClassName );
30 */ 30 */
31 class ExceptionBase : public std::exception 31 class ExceptionBase : public std::exception
32 { 32 {
33 public: 33 public:
34 /** 34 /**
35 * Construct an exception with an error code of zero, but with a 35 * Construct an exception with an error code of zero, but with a
36 * description. The use of this is not reccomended most of the time, 36 * description. The use of this is not reccomended most of the time,
37 * it's generally best to include an error code with the exception so 37 * it's generally best to include an error code with the exception so
38 * your program can handle the exception in a better way. 38 * your program can handle the exception in a better way.
39 * @param sFormat The format of the text. See printf for more info. 39 * @param sFormat The format of the text. See printf for more info.
40 */ 40 */
41 ExceptionBase( const char *sFormat, ... ) throw(); 41 ExceptionBase( const char *sFormat, ... ) throw();
42 42
43 /** 43 /**
44 * 44 *
45 * @param nCode 45 * @param nCode
46 * @param sFormat 46 * @param sFormat
47 */ 47 */
48 ExceptionBase( int nCode, const char *sFormat, ... ) throw(); 48 ExceptionBase( int nCode, const char *sFormat, ... ) throw();
49 49
50 /** 50 /**
51 * 51 *
52 * @param nCode 52 * @param nCode
53 * @return 53 * @return
54 */ 54 */
55 ExceptionBase( int nCode=0 ) throw(); 55 ExceptionBase( int nCode=0 ) throw();
56 56
57 ExceptionBase( const ExceptionBase &e ) throw (); 57 ExceptionBase( const ExceptionBase &e ) throw ();
58 58
59 /** 59 /**
60 * 60 *
61 * @return 61 * @return
62 */ 62 */
63 virtual ~ExceptionBase() throw(); 63 virtual ~ExceptionBase() throw();
64 64
65 /** 65 /**
66 * 66 *
67 * @return 67 * @return
68 */ 68 */
69 virtual const char *what() const throw(); 69 virtual const char *what() const throw();
70 70
71 /** 71 /**
72 * 72 *
73 * @return 73 * @return
74 */ 74 */
75 int getErrorCode(); 75 int getErrorCode();
76 76
77 /** 77 /**
78 * 78 *
79 * @param lpFormat 79 * @param lpFormat
80 * @param vargs 80 * @param vargs
81 */ 81 */
82 void setWhat( const char *lpFormat, va_list &vargs ); 82 void setWhat( const char *lpFormat, va_list &vargs );
83 83
84 /** 84 /**
85 * 85 *
86 * @param lpText 86 * @param lpText
87 */ 87 */
88 void setWhat( const char *lpText ); 88 void setWhat( const char *lpText );
89 89
90 private: 90 private:
91 int nErrorCode; /**< The code for the error that occured. */ 91 int nErrorCode; /**< The code for the error that occured. */
92 char *sWhat; /**< The text string telling people what went wrong. */ 92 char *sWhat; /**< The text string telling people what went wrong. */
93 }; 93 };
94} 94}
95 95
96#define subExceptionDecl( name ) \ 96#define subExceptionDecl( name ) \
97class name : public Bu::ExceptionBase \ 97class name : public Bu::ExceptionBase \
98{ \ 98{ \
99 public: \ 99 public: \
100 name( const char *sFormat, ... ) throw (); \ 100 name( const char *sFormat, ... ) throw (); \
101 name( int nCode, const char *sFormat, ... ) throw(); \ 101 name( int nCode, const char *sFormat, ... ) throw(); \
102 name( int nCode=0 ) throw (); \ 102 name( int nCode=0 ) throw (); \
103 name( const name &e ) throw (); \ 103 name( const name &e ) throw (); \
104}; 104};
105 105
106#define subExceptionDeclChild( name, parent ) \ 106#define subExceptionDeclChild( name, parent ) \
107class name : public parent \ 107class name : public parent \
108{ \ 108{ \
109 public: \ 109 public: \
110 name( const char *sFormat, ... ) throw (); \ 110 name( const char *sFormat, ... ) throw (); \
111 name( int nCode, const char *sFormat, ... ) throw(); \ 111 name( int nCode, const char *sFormat, ... ) throw(); \
112 name( int nCode=0 ) throw (); \ 112 name( int nCode=0 ) throw (); \
113 name( const name &e ) throw (); \ 113 name( const name &e ) throw (); \
114}; 114};
115 115
116#define subExceptionDeclBegin( name ) \ 116#define subExceptionDeclBegin( name ) \
117class name : public Bu::ExceptionBase \ 117class name : public Bu::ExceptionBase \
118{ \ 118{ \
119 public: \ 119 public: \
120 name( const char *sFormat, ... ) throw (); \ 120 name( const char *sFormat, ... ) throw (); \
121 name( int nCode, const char *sFormat, ... ) throw(); \ 121 name( int nCode, const char *sFormat, ... ) throw(); \
122 name( int nCode=0 ) throw (); \ 122 name( int nCode=0 ) throw (); \
123 name( const name &e ) throw (); 123 name( const name &e ) throw ();
124 124
125#define subExceptionDeclEnd() \ 125#define subExceptionDeclEnd() \
126}; 126};
127 127
128#define subExceptionDef( name ) \ 128#define subExceptionDef( name ) \
129name::name( const char *lpFormat, ... ) throw() : \ 129name::name( const char *lpFormat, ... ) throw() : \
130 ExceptionBase( 0 ) \ 130 ExceptionBase( 0 ) \
131{ \ 131{ \
132 va_list ap; \ 132 va_list ap; \
133 va_start( ap, lpFormat ); \ 133 va_start( ap, lpFormat ); \
134 setWhat( lpFormat, ap ); \ 134 setWhat( lpFormat, ap ); \
135 va_end( ap ); \ 135 va_end( ap ); \
136} \ 136} \
137name::name( int nCode, const char *lpFormat, ... ) throw() : \ 137name::name( int nCode, const char *lpFormat, ... ) throw() : \
138 ExceptionBase( nCode ) \ 138 ExceptionBase( nCode ) \
139{ \ 139{ \
140 va_list ap; \ 140 va_list ap; \
141 va_start( ap, lpFormat ); \ 141 va_start( ap, lpFormat ); \
142 setWhat( lpFormat, ap ); \ 142 setWhat( lpFormat, ap ); \
143 va_end( ap ); \ 143 va_end( ap ); \
144} \ 144} \
145name::name( int nCode ) throw() : \ 145name::name( int nCode ) throw() : \
146 ExceptionBase( nCode ) \ 146 ExceptionBase( nCode ) \
147{ \ 147{ \
148} \ 148} \
149name::name( const name &e ) throw() : \ 149name::name( const name &e ) throw() : \
150 ExceptionBase( e ) \ 150 ExceptionBase( e ) \
151{ \ 151{ \
152} 152}
153 153
154#define subExceptionDefChild( name, parent ) \ 154#define subExceptionDefChild( name, parent ) \
155name::name( const char *lpFormat, ... ) throw() : \ 155name::name( const char *lpFormat, ... ) throw() : \
156 parent( 0 ) \ 156 parent( 0 ) \
157{ \ 157{ \
158 va_list ap; \ 158 va_list ap; \
159 va_start( ap, lpFormat ); \ 159 va_start( ap, lpFormat ); \
160 setWhat( lpFormat, ap ); \ 160 setWhat( lpFormat, ap ); \
161 va_end( ap ); \ 161 va_end( ap ); \
162} \ 162} \
163name::name( int nCode, const char *lpFormat, ... ) throw() : \ 163name::name( int nCode, const char *lpFormat, ... ) throw() : \
164 parent( nCode ) \ 164 parent( nCode ) \
165{ \ 165{ \
166 va_list ap; \ 166 va_list ap; \
167 va_start( ap, lpFormat ); \ 167 va_start( ap, lpFormat ); \
168 setWhat( lpFormat, ap ); \ 168 setWhat( lpFormat, ap ); \
169 va_end( ap ); \ 169 va_end( ap ); \
170} \ 170} \
171name::name( int nCode ) throw() : \ 171name::name( int nCode ) throw() : \
172 parent( nCode ) \ 172 parent( nCode ) \
173{ \ 173{ \
174} \ 174} \
175name::name( const name &e ) throw() : \ 175name::name( const name &e ) throw() : \
176 ExceptionBase( e ) \ 176 ExceptionBase( e ) \
177{ \ 177{ \
178} 178}
179 179
180namespace Bu 180namespace Bu
181{ 181{
182 // Exceptions that are so general they could be used anywhere go here. 182 // Exceptions that are so general they could be used anywhere go here.
183 class UnsupportedException : public Bu::ExceptionBase 183 class UnsupportedException : public Bu::ExceptionBase
184 { 184 {
185 public: 185 public:
186 UnsupportedException() throw (); 186 UnsupportedException() throw ();
187 }; 187 };
188} 188}
189 189
190#endif 190#endif