GDCM_NAME_SPACE::Exception Class Reference

Any exception thrown in the gdcm library. More...

#include <gdcmException.h>

Inheritance diagram for GDCM_NAME_SPACE::Exception:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Exception (const std::string &from, const std::string &error="") throw ()
 constructor
virtual ~Exception () throw ()
 virtual destructor makes this class dynamic
const std::string & getError () const throw ()
 returns error message
virtual std::string getName () const throw ()
 getName
virtual const char * what () const throw ()
 returns exception name string (overloads std::exception::what)
 operator const char * () const throw ()
 Exception.

Static Public Member Functions

static void fatal (const char *from) throw ()
 fatal

Protected Attributes

std::string From
 error message part 1
std::string Error
 error message part 2

Friends

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

Detailed Description

Any exception thrown in the gdcm library.

Definition at line 35 of file gdcmException.h.


Constructor & Destructor Documentation

GDCM_NAME_SPACE::Exception::Exception const std::string &  f,
const std::string &  msg = ""
throw () [explicit]
 

constructor

Parameters:
f f
msg msg

Definition at line 33 of file gdcmException.cxx.

00037    : From(f), Error(msg) 
00038    {
00039    }

virtual GDCM_NAME_SPACE::Exception::~Exception  )  throw () [inline, virtual]
 

virtual destructor makes this class dynamic

Definition at line 50 of file gdcmException.h.

00050 {}


Member Function Documentation

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

fatal

Parameters:
from from

Definition at line 51 of file gdcmException.cxx.

Referenced by GDCM_NAME_SPACE::operator<<().

00052 {
00053    try
00054    {
00055       std::cerr << "Fatal: exception received in " << from 
00056                 << " while handling exception." << std::endl;
00057       exit(-1);
00058    }
00059    catch(...)
00060    {
00061       try
00062       {
00063          std::cerr << "Fatal: exception received in Exception::fatal while handling exception."
00064                    << std::endl;
00065          exit(-1);
00066       }
00067       catch(...)
00068       {
00069          exit(-1);
00070       }
00071    }
00072 }

const std::string& GDCM_NAME_SPACE::Exception::getError  )  const throw () [inline]
 

returns error message

Definition at line 56 of file gdcmException.h.

References Error().

Referenced by GDCM_NAME_SPACE::operator<<().

00056 { return Error;}

std::string GDCM_NAME_SPACE::Exception::getName  )  const throw () [virtual]
 

getName

Returns:
string

Definition at line 78 of file gdcmException.cxx.

Referenced by operator const char *(), and GDCM_NAME_SPACE::operator<<().

00079 {
00080    try
00081    {
00082 #if defined(__GNUC__) && 0   // GNU C++ compiler class name demangling
00083       unsigned int nested = 1, i, nb;
00084       int offset;
00085       std::string one;
00086 
00087       std::string name;
00088       std::string iname = typeid(*this).name();
00089       if ( iname[0] == 'Q' )
00090       {
00091          nested = iname[1] - '0';
00092          iname = std::string(iname, 2, std::string::npos);
00093       }
00094       for(i = 0; i < nested; i++)
00095       {
00096          ::sscanf(iname.c_str(), "%u%n", &nb, &offset);
00097          iname = std::string(iname, offset, std::string::npos);
00098          name += std::string(iname, 0, nb);
00099          if ( i + 1 < nested) name += "::";
00100          iname = std::string(iname, nb, std::string::npos );
00101       }
00102       return name;
00103 #else           // no class name demangling
00104       std::string name = typeid(*this).name();
00105       return name;
00106 #endif
00107    }
00108    catch(...) 
00109    {
00110       fatal("Exception::getName(std::string &)");
00111       return "";
00112    }
00113 }

GDCM_NAME_SPACE::Exception::operator const char *  )  const throw ()
 

Exception.

Definition at line 118 of file gdcmException.cxx.

References getName().

00119 {
00120    return getName().c_str();
00121 }

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

returns exception name string (overloads std::exception::what)

Definition at line 62 of file gdcmException.h.

00062 { return (const char *) *this;}


Friends And Related Function Documentation

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

Exception::operator <<.

Parameters:
os ostream to write to
e exception to raise

Definition at line 129 of file gdcmException.cxx.

00130 {
00131    try 
00132    {
00133       os << "Exception " << e.getName() << " thrown: " << e.getError() << std::endl;
00134    }
00135    catch(...) 
00136    {
00137       Exception::fatal("operator<<(std::ostream &, const Exception&)");
00138    }
00139    return os;
00140 }


Member Data Documentation

std::string GDCM_NAME_SPACE::Exception::Error [protected]
 

error message part 2

Definition at line 73 of file gdcmException.h.

std::string GDCM_NAME_SPACE::Exception::From [protected]
 

error message part 1

Definition at line 71 of file gdcmException.h.


The documentation for this class was generated from the following files:
Generated on Fri Aug 24 12:57:06 2007 for gdcm by  doxygen 1.4.6