Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

gdcmException Class Reference

#include <gdcmException.h>

Inheritance diagram for gdcmException:

gdcmFileError gdcmFormatError List of all members.

Public Member Functions

 gdcmException (const std::string &from, const std::string &error="") throw ()
virtual ~gdcmException () throw ()
const std::string & getError (void) const throw ()
virtual std::string getName () const throw ()
virtual const char * what () const throw ()
 operator const char * () const throw ()

Static Public Member Functions

void fatal (const char *from) throw ()

Protected Attributes

std::string from
std::string error

Friends

std::ostream & operator<< (std::ostream &os, const gdcmException &e)

Constructor & Destructor Documentation

gdcmException::gdcmException const std::string &  from,
const std::string &  error = ""
throw () [explicit]
 

Definition at line 16 of file gdcmException.cxx.

00020   : from(f), error(msg) {
00021   }

virtual gdcmException::~gdcmException  )  throw () [inline, virtual]
 

Definition at line 30 of file gdcmException.h.

00030                                     {
00031    }


Member Function Documentation

void gdcmException::fatal const char *  from  )  throw () [static]
 

Definition at line 34 of file gdcmException.cxx.

Referenced by operator<<().

00034                                                    {
00035   try {
00036     std::cerr << "Fatal: exception received in " << from 
00037          << " while handling exception." << std::endl;
00038     exit(-1);
00039   }
00040   catch(...) {
00041     try {
00042       std::cerr << "Fatal: exception received in Exception::fatal while handling exception."
00043            << std::endl;
00044       exit(-1);
00045     }
00046     catch(...) {
00047       exit(-1);
00048     }
00049   }  
00050 }

const std::string& gdcmException::getError void   )  const throw () [inline]
 

Definition at line 37 of file gdcmException.h.

Referenced by operator<<().

00037                                                  {
00038     return error;
00039    }

std::string gdcmException::getName  )  const throw () [virtual]
 

Definition at line 57 of file gdcmException.cxx.

Referenced by operator<<().

00057                                                 {
00058   try {
00059 #ifdef __GNUC__   // GNU C++ compiler class name demangling
00060       unsigned int nested = 1, i, nb, offset;
00061       std::string one;
00062 
00063       std::string name;
00064       std::string iname = typeid(*this).name();
00065       if(iname[0] == 'Q') {
00066         nested = iname[1] - '0';
00067         iname = std::string(iname, 2, std::string::npos);
00068       }
00069       for(i = 0; i < nested; i++) {
00070         ::sscanf(iname.c_str(), "%u%n", &nb, &offset);
00071         iname = std::string(iname, offset, std::string::npos);
00072         name += std::string(iname, 0, nb);
00073         if(i + 1 < nested) name += "::";
00074         iname = std::string(iname, nb, std::string::npos);
00075       }
00076       return name;
00077 #else             // no class name demangling
00078       //name = typeid(*this).name();
00079       return "Exception";
00080 #endif
00081   }
00082   catch(...) {
00083     fatal("Exception::getName(std::string &)");
00084     return "";
00085   }
00086 }

gdcmException::operator const char *  )  const throw ()
 

Definition at line 93 of file gdcmException.cxx.

00093                                                     {
00094   return getName().c_str();
00095 }

virtual const char* gdcmException::what  )  const throw () [inline, virtual]
 

Definition at line 45 of file gdcmException.h.

00045                                             {
00046     return (const char *) *this;
00047    }


Friends And Related Function Documentation

std::ostream& operator<< std::ostream &  os,
const gdcmException e
[friend]
 

Definition at line 103 of file gdcmException.cxx.

00103                                                                 {
00104   try {  
00105     os << "Exception " << e.getName() << " thrown: " << e.getError() << std::endl;
00106   }
00107   catch(...) {
00108     gdcmException::fatal("operator<<(std::ostream &, const gdcmException&)");
00109   }
00110   return os;
00111 }


Member Data Documentation

std::string gdcmException::error [protected]
 

Definition at line 58 of file gdcmException.h.

std::string gdcmException::from [protected]
 

Definition at line 56 of file gdcmException.h.


The documentation for this class was generated from the following files:
Generated on Mon Feb 14 16:13:37 2005 for gdcm by doxygen 1.3.6