File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -412,7 +412,7 @@ inline TypeInfo readTypeInfo( tinyxml2::XMLElement const * element )
412412 }
413413 if ( typeInfo.prefix .starts_with ( " const" ) )
414414 {
415- typeInfo.prefix = trim ( typeInfo.prefix .substr ( 5 ) );
415+ typeInfo.prefix = trim ( typeInfo.prefix .substr ( 5 ) );
416416 typeInfo.postfix = ( typeInfo.postfix .empty () ? " const" : ( " const " + typeInfo.postfix ) );
417417 }
418418 return typeInfo;
@@ -558,18 +558,18 @@ inline std::string toString( tinyxml2::XMLError error )
558558
559559std::string toUpperCase ( std::string const & name )
560560{
561+ assert ( !name.empty () );
561562 std::string convertedName;
562- bool previousIsLowerCase = false ;
563- bool previousIsDigit = false ;
564- for ( auto c : name )
563+ convertedName. push_back ( static_cast < char >( toupper ( name. front () ) ) ) ;
564+ size_t n = name. length () ;
565+ for ( size_t i = 1 ; i < n; ++i )
565566 {
566- if ( ( isupper ( c ) && ( previousIsLowerCase || previousIsDigit ) ) || ( isdigit ( c ) && previousIsLowerCase ) )
567+ if ( ( isupper ( name[i] ) && ( islower ( name[i - 1 ] ) || isdigit ( name[i - 1 ] ) || ( ( i < n - 1 ) && islower ( name[i + 1 ] ) ) ) ) ||
568+ ( isdigit ( name[i] ) && islower ( name[i - 1 ] ) ) )
567569 {
568570 convertedName.push_back ( ' _' );
569571 }
570- convertedName.push_back ( static_cast <char >( toupper ( c ) ) );
571- previousIsLowerCase = !!islower ( c );
572- previousIsDigit = !!isdigit ( c );
572+ convertedName.push_back ( static_cast <char >( toupper ( name[i] ) ) );
573573 }
574574 return convertedName;
575575}
You can’t perform that action at this time.
0 commit comments