Re: [Cppunit-devel] questionable code @ TypeInfoHelper.cpp
Brought to you by:
blep
|
From: Baptiste L. <gai...@fr...> - 2002-04-19 10:51:47
|
I did this instead (remove the ugly #ifdef):
std::string
TypeInfoHelper::getClassName( const std::type_info &info )
{
static std::string classPrefix( "class " );
std::string name( info.name() );
if ( name.substr( 0, classPrefix.length() ) == classPrefix )
return name.substr( classPrefix.length() );
return name;
}
Let me know if it's works.
Baptiste.
PS: is there any reason for comparing the size() with the length() ?
----- Original Message -----
From: "FUKUDA Fumiki" <ff...@nt...>
To: <cpp...@li...>
Sent: Thursday, April 18, 2002 9:05 AM
Subject: [Cppunit-devel] questionable code @ TypeInfoHelper.cpp
> Hi all,
>
> ----- excerpt from src/cppunit/TypeInfoHelper.cpp -----
> std::string
> TypeInfoHelper::getClassName( const std::type_info &info )
> {
> static std::string classPrefix( "class " );
> std::string name( info.name() );
>
> bool has_class_prefix = 0 ==
> #if CPPUNIT_FUNC_STRING_COMPARE_STRING_FIRST
> name.compare( classPrefix, 0, classPrefix.length() );
> #else
> name.compare( 0, classPrefix.length(), classPrefix );
> #endif
> return has_class_prefix ? name.substr( classPrefix.length() ) : name;
> }
> ------------------
>
> if info.name().length() < classPrefix.length(), an exception should be
thrown.
> I think this method should return 'name' at this condition (as follows).
>
> ...
> static std::string classPrefix( "class " );
> std::string name( info.name() );
>
> if ( name.length() < classPrefix.size() ) return name; // ADD THIS!
>
> bool has_class_prefix = 0 == ...
>
> -----:-----:-----:-----:-----:-----:-----:-----:-----:-----
> FUKUDA (episteme) Fumiki -- magical, but never a magic...
>
> _______________________________________________
> Cppunit-devel mailing list
> Cpp...@li...
> https://lists.sourceforge.net/lists/listinfo/cppunit-devel
>
|