]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Single out some functions from exceptions.h to reduce computational requirements...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 13 Dec 1998 20:57:47 +0000 (20:57 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Sun, 13 Dec 1998 20:57:47 +0000 (20:57 +0000)
git-svn-id: https://svn.dealii.org/trunk@705 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/source/exceptions.cc [new file with mode: 0644]

diff --git a/deal.II/base/source/exceptions.cc b/deal.II/base/source/exceptions.cc
new file mode 100644 (file)
index 0000000..f0fab56
--- /dev/null
@@ -0,0 +1,89 @@
+/*      $Id$                 */
+
+
+#include <base/exceptions.h>
+#include <string>
+#include <strstream>
+
+
+
+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();
+};
+

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.