GDCM_NAME_SPACE::FormatError Class Reference

Invalid file format exception. More...

#include <gdcmException.h>

Inheritance diagram for GDCM_NAME_SPACE::FormatError:

Inheritance graph
[legend]
Collaboration diagram for GDCM_NAME_SPACE::FormatError:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FormatError (const std::string &from, const std::string &error="Invalid file format") throw ()
 Builds a file-related exception with minimal information: name of the thrower method and error message.
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

Invalid file format exception.

Definition at line 116 of file gdcmException.h.


Constructor & Destructor Documentation

GDCM_NAME_SPACE::FormatError::FormatError const std::string &  from,
const std::string &  error = "Invalid file format"
throw () [inline, explicit]
 

Builds a file-related exception with minimal information: name of the thrower method and error message.

Parameters:
from name of the thrower
error error description string

Definition at line 123 of file gdcmException.h.

00125               : FormatUnexpected( from, error ) { }


Member Function Documentation

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

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, inherited]
 

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, inherited]
 

getName

Returns:
string

Definition at line 78 of file gdcmException.cxx.

Referenced by GDCM_NAME_SPACE::Exception::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 () [inherited]
 

Exception.

Definition at line 118 of file gdcmException.cxx.

References GDCM_NAME_SPACE::Exception::getName().

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

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

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, inherited]
 

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, inherited]
 

error message part 2

Definition at line 73 of file gdcmException.h.

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

error message part 1

Definition at line 71 of file gdcmException.h.


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