head 1.4; access; symbols; locks; strict; comment @# @; 1.4 date 2002.09.07.01.50.38; author curt; state Exp; branches; next 1.3; 1.3 date 2002.08.31.19.01.53; author curt; state Exp; branches; next 1.2; 1.2 date 2002.08.31.18.54.00; author curt; state Exp; branches; next 1.1; 1.1 date 2002.02.15.17.21.56; author curt; state Exp; branches; next ; desc @@ 1.4 log @Updated doxygen docs. @ text @
Main Page Class Hierarchy Compound List File List Compound Members File Members

# exception.cxx

    00001 // exception.cxx - implementation of SimGear base exceptions.
    00002 // Started Summer 2001 by David Megginson, david@@megginson.com
    00003 // This code is released into the Public Domain.
    00004 //
    00005 // $Id: exception.cxx,v 1.3 2001/10/24 19:59:05 curt Exp $
    00006
    00007
    00008 #include "exception.hxx"
    00009 #include <stdio.h>
    00010
    00011
    00013 // Implementation of sg_location class.
    00015
    00016 sg_location::sg_location ()
    00017   : _path(""),
    00018     _line(-1),
    00019     _column(-1),
    00020     _byte(-1)
    00021 {
    00022 }
    00023
    00024 sg_location::sg_location (const string &path, int line, int column)
    00025   : _path(path),
    00026     _line(line),
    00027     _column(column),
    00028     _byte(-1)
    00029 {
    00030 }
    00031
    00032 sg_location::~sg_location ()
    00033 {
    00034 }
    00035
    00036 const string &
    00037 sg_location::getPath () const
    00038 {
    00039   return _path;
    00040 }
    00041
    00042 void
    00043 sg_location::setPath (const string &path)
    00044 {
    00045   _path = path;
    00046 }
    00047
    00048 int
    00049 sg_location::getLine () const
    00050 {
    00051   return _line;
    00052 }
    00053
    00054 void
    00055 sg_location::setLine (int line)
    00056 {
    00057   _line = line;
    00058 }
    00059
    00060 int
    00061 sg_location::getColumn () const
    00062 {
    00063   return _column;
    00064 }
    00065
    00066 void
    00067 sg_location::setColumn (int column)
    00068 {
    00069   _column = column;
    00070 }
    00071
    00072 int
    00073 sg_location::getByte () const
    00074 {
    00075   return _byte;
    00076 }
    00077
    00078 void
    00079 sg_location::setByte (int byte)
    00080 {
    00081   _byte = byte;
    00082 }
    00083
    00084 string
    00085 sg_location::asString () const
    00086 {
    00087   char buf[128];
    00088   string out = "";
    00089   if (_path != (string)"") {
    00090     out += _path;
    00091     if (_line != -1 || _column != -1)
    00092       out += ",\n";
    00093   }
    00094   if (_line != -1) {
    00095     sprintf(buf, "line %d", _line);
    00096     out += buf;
    00097     if (_column != -1)
    00098       out += ", ";
    00099   }
    00100   if (_column != -1) {
    00101     sprintf(buf, "column %d", _column);
    00102     out += buf;
    00103   }
    00104   return out;
    00105
    00106 }
    00107
    00108
    00109
    00111 // Implementation of sg_throwable class.
    00113
    00114 sg_throwable::sg_throwable ()
    00115   : _message(""),
    00116     _origin("")
    00117 {
    00118 }
    00119
    00120 sg_throwable::sg_throwable (const string &message, const string &origin)
    00121   : _message(message),
    00122     _origin(origin)
    00123 {
    00124 }
    00125
    00126 sg_throwable::~sg_throwable ()
    00127 {
    00128 }
    00129
    00130 const string &
    00131 sg_throwable::getMessage () const
    00132 {
    00133   return _message;
    00134 }
    00135
    00136 const string
    00137 sg_throwable::getFormattedMessage () const
    00138 {
    00139   return getMessage();
    00140 }
    00141
    00142 void
    00143 sg_throwable::setMessage (const string &message)
    00144 {
    00145   _message = message;
    00146 }
    00147
    00148 const string &
    00149 sg_throwable::getOrigin () const
    00150 {
    00151   return _origin;
    00152 }
    00153
    00154 void
    00155 sg_throwable::setOrigin (const string &origin)
    00156 {
    00157   _origin = origin;
    00158 }
    00159
    00160
    00161
    00163 // Implementation of sg_error class.
    00165
    00166 sg_error::sg_error ()
    00167   : sg_throwable ()
    00168 {
    00169 }
    00170
    00171 sg_error::sg_error (const string &message, const string &origin)
    00172   : sg_throwable(message, origin)
    00173 {
    00174 }
    00175
    00176 sg_error::~sg_error ()
    00177 {
    00178 }
    00179
    00180
    00181
    00183 // Implementation of sg_exception class.
    00185
    00186 sg_exception::sg_exception ()
    00187   : sg_throwable ()
    00188 {
    00189 }
    00190
    00191 sg_exception::sg_exception (const string &message, const string &origin)
    00192   : sg_throwable(message, origin)
    00193 {
    00194 }
    00195
    00196 sg_exception::~sg_exception ()
    00197 {
    00198 }
    00199
    00200
    00201
    00203 // Implementation of sg_io_exception.
    00205
    00206 sg_io_exception::sg_io_exception ()
    00207   : sg_exception()
    00208 {
    00209 }
    00210
    00211 sg_io_exception::sg_io_exception (const string &message, const string &origin)
    00212   : sg_exception(message, origin)
    00213 {
    00214 }
    00215
    00216 sg_io_exception::sg_io_exception (const string &message,
    00217                                   const sg_location &location,
    00218                                   const string &origin)
    00219   : sg_exception(message, origin),
    00220     _location(location)
    00221 {
    00222 }
    00223
    00224 sg_io_exception::~sg_io_exception ()
    00225 {
    00226 }
    00227
    00228 const string
    00229 sg_io_exception::getFormattedMessage () const
    00230 {
    00231   string ret = getMessage();
    00232   ret += "\n at ";
    00233   ret += getLocation().asString();
    00234   return ret;
    00235 }
    00236
    00237 const sg_location &
    00238 sg_io_exception::getLocation () const
    00239 {
    00240   return _location;
    00241 }
    00242
    00243 void
    00244 sg_io_exception::setLocation (const sg_location &location)
    00245 {
    00246   _location = location;
    00247 }
    00248
    00249
    00250
    00252 // Implementation of sg_format_exception.
    00254
    00255 sg_format_exception::sg_format_exception ()
    00256   : sg_exception(),
    00257     _text("")
    00258 {
    00259 }
    00260
    00261 sg_format_exception::sg_format_exception (const string &message,
    00262                                           const string &text,
    00263                                           const string &origin)
    00264   : sg_exception(message, origin),
    00265     _text(text)
    00266 {
    00267 }
    00268
    00269 sg_format_exception::~sg_format_exception ()
    00270 {
    00271 }
    00272
    00273 const string &
    00274 sg_format_exception::getText () const
    00275 {
    00276   return _text;
    00277 }
    00278
    00279 void
    00280 sg_format_exception::setText (const string &text)
    00281 {
    00282   _text = text;
    00283 }
    00284
    00285
    00286
    00288 // Implementation of sg_range_exception.
    00290
    00291 sg_range_exception::sg_range_exception ()
    00292   : sg_exception()
    00293 {
    00294 }
    00295
    00296 sg_range_exception::sg_range_exception (const string &message,
    00297                                         const string &origin)
    00298   : sg_exception(message, origin)
    00299 {
    00300 }
    00301
    00302 sg_range_exception::~sg_range_exception ()
    00303 {
    00304 }
    00305
    00306
    00307 // end of exception.cxx

@ 1.3 log @Oops, try again. @ text @d302 1 a302 1