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"
17 gdcmException::gdcmException(const std::string &f, const std::string& msg) throw()
21 : from(f), error(msg) {
25 fatal("gdcmException::gdcmException(const std::string&, const std::string&, const std::string&)");
31 void gdcmException::fatal(const char *from) throw() {
33 std::cerr << "Fatal: exception received in " << from
34 << " while handling exception." << std::endl;
39 std::cerr << "Fatal: exception received in Exception::fatal while handling exception."
50 std::string gdcmException::getName() const throw() {
52 #ifdef __GNUC__ // GNU C++ compiler class name demangling
53 unsigned int nested = 1, i, nb, offset;
57 std::string iname = typeid(*this).name();
59 nested = iname[1] - '0';
60 iname = std::string(iname, 2, std::string::npos);
62 for(i = 0; i < nested; i++) {
63 ::sscanf(iname.c_str(), "%u%n", &nb, &offset);
64 iname = std::string(iname, offset, std::string::npos);
65 name += std::string(iname, 0, nb);
66 if(i + 1 < nested) name += "::";
67 iname = std::string(iname, nb, std::string::npos);
70 #else // no class name demangling
71 //name = typeid(*this).name();
76 fatal("Exception::getName(std::string &)");
82 gdcmException::operator const char *() const throw() {
83 return getName().c_str();
87 std::ostream& operator<<(std::ostream &os, const gdcmException &e) {
89 os << "Exception " << e.getName() << " thrown: " << e.getError() << std::endl;
92 gdcmException::fatal("operator<<(ostream &, const gdcmException&)");