From: wolf Date: Sun, 13 Dec 1998 20:57:47 +0000 (+0000) Subject: Single out some functions from exceptions.h to reduce computational requirements... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fdbd76427ad1aa3044cb9d2a6a38a8213933bddf;p=dealii-svn.git Single out some functions from exceptions.h to reduce computational requirements when compiling. This does not affect run time of programs. git-svn-id: https://svn.dealii.org/trunk@705 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/source/exceptions.cc b/deal.II/base/source/exceptions.cc new file mode 100644 index 0000000000..f0fab5687d --- /dev/null +++ b/deal.II/base/source/exceptions.cc @@ -0,0 +1,89 @@ +/* $Id$ */ + + +#include +#include +#include + + + +ExceptionBase::ExceptionBase () : + file(""), line(0), function(""), cond(""), exc("") +{}; + + + +ExceptionBase::ExceptionBase (const char* f, const int l, const char *func, + const char* c, const char *e) : + file(f), line(l), function(func), cond(c), exc(e) +{}; + + + +void ExceptionBase::SetFields (const char* f, + const int l, + const char *func, + const char *c, + const char *e) { + file = f; + line = l; + function = func; + cond = c; + exc = e; +}; + + + +void ExceptionBase::PrintExcData (ostream &out) const { + out << "An error occurred in line <" << line + << "> of file <" << file + << "> in function" << endl + << " " << function << endl + << "The violated condition was: "<< endl + << " " << cond << endl + << "The name and call sequence of the exception was:" << endl + << " " << exc << endl + << "Additional Information: " << endl; +}; + + + + +void ExceptionBase::PrintInfo (ostream &out) const { + out << "(none)" << endl; +}; + + + +const char * ExceptionBase::what () const { + // have a place where to store the + // description of the exception as a char * + // + // this thing obviously is not multi-threading + // safe, but we don't care about that for now + // + // we need to make this object static, since + // we want to return the data stored in it + // and therefore need a liftime which is + // longer than the execution time of this + // function + static string description; + // convert the messages printed by the + // exceptions into a string + ostrstream converter; + + converter << "--------------------------------------------------------" + << endl; + // put general info into the string + PrintExcData (converter); + // put in exception specific data + PrintInfo (converter); + + converter << "--------------------------------------------------------" + << endl; + + description = converter.str(); + + return description.c_str(); +}; +