CMS 3D CMS Logo

ClassName.h

Go to the documentation of this file.
00001 #ifndef UTILITIES_GENERAL_CLASSNAME_H
00002 #define UTILITIES_GENERAL_CLASSNAME_H
00003 //
00004 #include <typeinfo>
00005 #include <string>
00006 
00007 inline std::string firstNonNumeric(const char * sc) {
00008   std::string s(sc);
00009   size_t  pos = s.find_first_not_of("0123456789");
00010   s.erase(0,pos);
00011   return s;
00012 }
00013 
00014 class Demangle {
00015 public:
00016   Demangle(const char * sc);
00017 
00018   const char * operator()() const { return demangle;}
00019   
00020   ~Demangle() { if (demangle) free((void*)demangle); }
00021   
00022 private:
00023   
00024   char * demangle;
00025 };
00026 
00027 
00028 template<class T>
00029 inline  std::string className(const T&t) { 
00030   return std::string(Demangle(typeid(t).name())());
00031 }
00032 
00033 template<class T>
00034 class ClassName {
00035 public:
00036   static const std::string & name() {
00037     static const std::string ln(Demangle(typeid(T).name())());
00038     return ln;
00039   }
00040 };
00041 
00042 #endif // UTILITIES_GENERAL_CLASSNAME_H

Generated on Tue Jun 9 17:48:44 2009 for CMSSW by  doxygen 1.5.4