Merge pull request #651 from asuessenbach/trimStars

Improve interpretation of type postfixes.
This commit is contained in:
Andreas Süßenbach 2020-06-25 16:58:14 +02:00 committed by GitHub
commit 5cce0f8380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -87,6 +87,7 @@ std::string toUpperCase( std::string const & name );
std::vector<std::string> tokenize( std::string const & tokenString, std::string const & separator );
std::string trim( std::string const & input );
std::string trimEnd( std::string const & input );
std::string trimStars( std::string const & input );
void warn( bool condition, int line, std::string const & message );
const std::set<std::string> nonConstSTypeStructs = { "VkBaseInStructure", "VkBaseOutStructure" };
@ -577,7 +578,7 @@ std::string readTypePostfix( tinyxml2::XMLNode const * node )
std::string postfix;
if ( node && node->ToText() )
{
postfix = trimEnd( node->Value() );
postfix = trimStars( trimEnd( node->Value() ) );
}
return postfix;
}
@ -751,6 +752,26 @@ std::string trimEnd( std::string const & input )
return result;
}
std::string trimStars( std::string const & input )
{
std::string result = input;
size_t pos = result.find( '*' );
while ( pos != std::string::npos )
{
if ( ( 0 < pos ) && ( result[pos - 1] != ' ' ) && ( result[pos - 1] != '*' ) )
{
result.insert( pos, 1, ' ' );
++pos;
}
else if ( ( pos < result.length() - 1 ) && ( result[pos + 1] != ' ' ) && ( result[pos + 1] != '*' ) )
{
result.insert( pos + 1, 1, ' ' );
}
pos = result.find( '*', pos+1 );
}
return result;
}
void warn( bool condition, int line, std::string const & message )
{
if ( !condition )