~ubuntu-branches/ubuntu/oneiric/psi/oneiric

« back to all changes in this revision

Viewing changes to third-party/cppunit/cppunit/src/cppunit/TypeInfoHelper.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2009-09-25 17:49:51 UTC
  • mfrom: (6.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090925174951-lvm7kdap82o8xhn3
Tags: 0.13-1
* Updated to upstream version 0.13
* Set Standards-Version to 3.8.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <cppunit/Portability.h>
2
 
#include <cppunit/extensions/TypeInfoHelper.h>
3
 
 
4
 
#if CPPUNIT_HAVE_RTTI
5
 
 
6
 
#include <string>
7
 
 
8
 
#if CPPUNIT_HAVE_GCC_ABI_DEMANGLE
9
 
#include <cxxabi.h>
10
 
#endif
11
 
 
12
 
 
13
 
CPPUNIT_NS_BEGIN
14
 
 
15
 
 
16
 
std::string 
17
 
TypeInfoHelper::getClassName( const std::type_info &info )
18
 
{
19
 
#if defined(CPPUNIT_HAVE_GCC_ABI_DEMANGLE)  &&  CPPUNIT_HAVE_GCC_ABI_DEMANGLE
20
 
 
21
 
  int status = 0;
22
 
  char* c_name = 0;
23
 
 
24
 
  c_name = abi::__cxa_demangle( info.name(), 0, 0, &status );
25
 
  
26
 
  std::string name( c_name );
27
 
  free( c_name );  
28
 
 
29
 
#else   // CPPUNIT_HAVE_GCC_ABI_DEMANGLE
30
 
 
31
 
  static std::string classPrefix( "class " );
32
 
  std::string name( info.name() );
33
 
 
34
 
  // Work around gcc 3.0 bug: strip number before type name.
35
 
  unsigned int firstNotDigitIndex = 0;
36
 
  while ( firstNotDigitIndex < name.length()  &&
37
 
          name[firstNotDigitIndex] >= '0'  &&
38
 
          name[firstNotDigitIndex] <= '9' )
39
 
    ++firstNotDigitIndex;
40
 
  name = name.substr( firstNotDigitIndex );
41
 
 
42
 
  if ( name.substr( 0, classPrefix.length() ) == classPrefix )
43
 
    return name.substr( classPrefix.length() );
44
 
 
45
 
#endif  // CPPUNIT_HAVE_GCC_ABI_DEMANGLE
46
 
 
47
 
  return name;
48
 
}
49
 
 
50
 
 
51
 
CPPUNIT_NS_END
52
 
 
53
 
#endif // CPPUNIT_HAVE_RTTI