gdcmException.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef __gdcmException_h
00016 #define __gdcmException_h
00017
00018 #include <string>
00019 #include <stdexcept>
00020 #include <sstream>
00021
00022 #include "gdcmTypes.h"
00023
00024 #include <assert.h>
00025
00026
00027 namespace gdcm
00028 {
00029
00035 class Exception : public std::exception
00036 {
00037 public:
00038 Exception(const char *desc = "None",
00039 const char *file = __FILE__,
00040 unsigned int lineNumber = __LINE__,
00041 const char *loc = "" )
00042 {
00043 Description = desc;
00044 File = file;
00045 Line = lineNumber;
00046 Location = loc;
00047 }
00048
00049 virtual ~Exception() throw() {}
00050
00052 Exception &operator= ( const Exception &orig )
00053 {
00054
00055 (void)orig;
00056 return *this;
00057 }
00058
00060 virtual bool operator==( const Exception &orig )
00061 {
00062 (void)orig;
00063 return true;
00064 }
00065
00067 const char* what() const throw()
00068 {
00069 static std::string strwhat;
00070 std::ostringstream oswhat;
00071 oswhat << File << ":" << Line << ":\n";
00072 oswhat << Description;
00073 strwhat = oswhat.str();
00074 return strwhat.c_str();
00075 }
00076
00078 const char * GetDescription() const { return Description.c_str(); }
00079
00080 private:
00081 std::string Description;
00082 std::string File;
00083 unsigned int Line;
00084 std::string Location;
00085 };
00086
00087 }
00088
00089 #endif
00090