00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifdef HAVE_CONFIG_H
00033 #include "config.h"
00034 #endif
00035
00036 #ifdef HAVE_STRING_H
00037 #include <string.h>
00038 #else
00039 #error need string.h
00040 #endif
00041
00042
00043 #include "Exception.h"
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 static const char fileid[] = "$Id: Exception.cpp,v 1.6 2002/05/28 12:35:41 darkeye Exp $";
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 Exception :: Exception ( const char * file,
00066 unsigned int line,
00067 const char * description1,
00068 const char * description2,
00069 int code ) throw ()
00070 {
00071 size_t len = 0;
00072
00073 if ( description1 ) {
00074 len += strlen( description1);
00075 }
00076 if ( description2 ) {
00077 len += strlen( description2);
00078 }
00079
00080 if ( len ) {
00081 char * str = new char[len+1];
00082
00083 str[0] = '\0';
00084 if ( description1 ) {
00085 strcat( str, description1);
00086 }
00087 if ( description2 ) {
00088 strcat( str, description2);
00089 }
00090
00091 init( file, line, str, code);
00092 delete[] str;
00093
00094 } else {
00095
00096 init( file, line, 0, code);
00097 }
00098 }
00099
00100
00101
00102
00103
00104 Exception :: Exception ( const char * file,
00105 unsigned int line,
00106 const char * description1,
00107 const char * description2,
00108 const char * description3,
00109 int code ) throw ()
00110 {
00111 size_t len = 0;
00112
00113 if ( description1 ) {
00114 len += strlen( description1);
00115 }
00116 if ( description2 ) {
00117 len += strlen( description2);
00118 }
00119 if ( description3 ) {
00120 len += strlen( description3);
00121 }
00122
00123 if ( len ) {
00124 char * str = new char[len+1];
00125
00126 str[0] = '\0';
00127 if ( description1 ) {
00128 strcat( str, description1);
00129 }
00130 if ( description2 ) {
00131 strcat( str, description2);
00132 }
00133 if ( description3 ) {
00134 strcat( str, description3);
00135 }
00136
00137 init( file, line, str, code);
00138 delete[] str;
00139
00140 } else {
00141
00142 init( file, line, 0, code);
00143 }
00144 }
00145
00146
00147
00148
00149
00150 void
00151 Exception :: init ( const char * file,
00152 unsigned int line,
00153 const char * description = 0,
00154 int code = 0 ) throw ()
00155 {
00156 if ( !file ) {
00157 this->file = 0;
00158 } else {
00159 size_t len;
00160
00161 len = strlen( file ) + 1;
00162 this->file = new char[len];
00163 if ( this->file ) {
00164 memcpy( this->file, file, len);
00165 }
00166 }
00167
00168 if ( !description ) {
00169 this->description = 0;
00170 } else {
00171 size_t len;
00172
00173 len = strlen( description ) + 1;
00174 this->description = new char[len];
00175 if ( this->description ) {
00176 memcpy( this->description, description, len);
00177 }
00178 }
00179
00180 this->line = line;
00181 this->code = code;
00182 }
00183
00184
00185
00186
00187
00188 void
00189 Exception :: strip ( void ) throw ()
00190 {
00191 if ( description ) {
00192 delete[] description;
00193 }
00194
00195 if ( file ) {
00196 delete[] file;
00197 }
00198 }
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228