2 //'identifier' : not all control paths return a value
3 //#pragma warning ( disable : 4715 )
4 // 'identifier' : class 'type' needs to have dll-interface to be used by
5 // clients of class 'type2'
6 #pragma warning ( disable : 4251 )
7 // 'identifier' : identifier was truncated to 'number' characters in the
9 #pragma warning ( disable : 4786 )
12 #include "gdcmException.h"
19 gdcmException::gdcmException(const string &f, const string& msg) throw()
23 : from(f), error(msg) {
27 fatal("gdcmException::gdcmException(const std::string&, const std::string&, const std::string&)");
33 void gdcmException::fatal(const char *from) throw() {
35 cerr << "Fatal: exception received in " << from
36 << " while handling exception." << endl;
41 cerr << "Fatal: exception received in Exception::fatal while handling exception."
52 string gdcmException::getName() const throw() {
54 #ifdef __GNUC__ // GNU C++ compiler class name demangling
55 unsigned int nested = 1, i, nb, offset;
59 string iname = typeid(*this).name();
61 nested = iname[1] - '0';
62 iname = string(iname, 2, std::string::npos);
64 for(i = 0; i < nested; i++) {
65 ::sscanf(iname.c_str(), "%u%n", &nb, &offset);
66 iname = string(iname, offset, std::string::npos);
67 name += string(iname, 0, nb);
68 if(i + 1 < nested) name += "::";
69 iname = string(iname, nb, std::string::npos);
72 #else // no class name demangling
73 //name = typeid(*this).name();
78 fatal("Exception::getName(string &)");
84 gdcmException::operator const char *() const throw() {
85 return getName().c_str();
89 ostream& operator<<(ostream &os, const gdcmException &e) {
91 os << "Exception " << e.getName() << " thrown: " << e.getError() << endl;
94 gdcmException::fatal("operator<<(ostream &, const gdcmException&)");