Merge pull request #1451 from asuessenbach/equal
Use std::equal to compare array of null-terminated strings in structs.
This commit is contained in:
commit
81cd1565e6
@ -533,9 +533,9 @@ void VulkanHppGenerator::addCommand( std::string const & name, CommandData & com
|
|||||||
std::map<std::string, HandleData>::iterator handleIt = m_handles.find( commandData.params[0].type.type );
|
std::map<std::string, HandleData>::iterator handleIt = m_handles.find( commandData.params[0].type.type );
|
||||||
if ( handleIt == m_handles.end() )
|
if ( handleIt == m_handles.end() )
|
||||||
{
|
{
|
||||||
handleIt = m_handles.find( "" );
|
handleIt = m_handles.begin();
|
||||||
|
assert( handleIt->first == "" );
|
||||||
}
|
}
|
||||||
assert( handleIt != m_handles.end() );
|
|
||||||
commandData.handle = handleIt->first;
|
commandData.handle = handleIt->first;
|
||||||
|
|
||||||
// add this command to the list of commands
|
// add this command to the list of commands
|
||||||
@ -9003,16 +9003,10 @@ std::string VulkanHppGenerator::generateStructCompareOperators( std::pair<std::s
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert( member.len[1] == "null-terminated" );
|
assert( member.len[1] == "null-terminated" );
|
||||||
static const std::string commpareMemberTemplate = R"( [this, rhs]
|
assert( ( member.type.prefix == "const" ) && ( member.type.postfix == "* const *" ) );
|
||||||
{
|
static const std::string compareMemberTemplate =
|
||||||
bool equal = true;
|
R"(std::equal( ${name}, ${name} + ${count}, rhs.${name}, []( char const * left, char const * right ) { return ( left == right ) || ( strcmp( left, right ) == 0 ); } ))";
|
||||||
for ( size_t i = 0; equal && ( i < ${count} ); ++i )
|
compareMembers += intro + replaceWithMap( compareMemberTemplate, { { "count", member.len[0] }, { "name", member.name } } );
|
||||||
{
|
|
||||||
equal = ( ( ${name}[i] == rhs.${name}[i] ) || ( strcmp( ${name}[i], rhs.${name}[i] ) == 0 ) );
|
|
||||||
}
|
|
||||||
return equal;
|
|
||||||
}())";
|
|
||||||
compareMembers += intro + replaceWithMap( commpareMemberTemplate, { { "count", member.len[0] }, { "name", member.name } } );
|
|
||||||
|
|
||||||
static const std::string spaceshipMemberTemplate = R"( for ( size_t i = 0; i < ${count}; ++i )
|
static const std::string spaceshipMemberTemplate = R"( for ( size_t i = 0; i < ${count}; ++i )
|
||||||
{
|
{
|
||||||
|
@ -23531,25 +23531,16 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
{
|
{
|
||||||
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) && ( queueCreateInfoCount == rhs.queueCreateInfoCount ) &&
|
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) && ( queueCreateInfoCount == rhs.queueCreateInfoCount ) &&
|
||||||
( pQueueCreateInfos == rhs.pQueueCreateInfos ) && ( enabledLayerCount == rhs.enabledLayerCount ) &&
|
( pQueueCreateInfos == rhs.pQueueCreateInfos ) && ( enabledLayerCount == rhs.enabledLayerCount ) &&
|
||||||
[this, rhs]
|
std::equal( ppEnabledLayerNames,
|
||||||
{
|
ppEnabledLayerNames + enabledLayerCount,
|
||||||
bool equal = true;
|
rhs.ppEnabledLayerNames,
|
||||||
for ( size_t i = 0; equal && ( i < enabledLayerCount ); ++i )
|
[]( char const * left, char const * right ) { return ( left == right ) || ( strcmp( left, right ) == 0 ); } ) &&
|
||||||
{
|
( enabledExtensionCount == rhs.enabledExtensionCount ) &&
|
||||||
equal = ( ( ppEnabledLayerNames[i] == rhs.ppEnabledLayerNames[i] ) || ( strcmp( ppEnabledLayerNames[i], rhs.ppEnabledLayerNames[i] ) == 0 ) );
|
std::equal( ppEnabledExtensionNames,
|
||||||
}
|
ppEnabledExtensionNames + enabledExtensionCount,
|
||||||
return equal;
|
rhs.ppEnabledExtensionNames,
|
||||||
}() && ( enabledExtensionCount == rhs.enabledExtensionCount ) &&
|
[]( char const * left, char const * right ) { return ( left == right ) || ( strcmp( left, right ) == 0 ); } ) &&
|
||||||
[this, rhs]
|
( pEnabledFeatures == rhs.pEnabledFeatures );
|
||||||
{
|
|
||||||
bool equal = true;
|
|
||||||
for ( size_t i = 0; equal && ( i < enabledExtensionCount ); ++i )
|
|
||||||
{
|
|
||||||
equal = ( ( ppEnabledExtensionNames[i] == rhs.ppEnabledExtensionNames[i] ) ||
|
|
||||||
( strcmp( ppEnabledExtensionNames[i], rhs.ppEnabledExtensionNames[i] ) == 0 ) );
|
|
||||||
}
|
|
||||||
return equal;
|
|
||||||
}() && ( pEnabledFeatures == rhs.pEnabledFeatures );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=( DeviceCreateInfo const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator!=( DeviceCreateInfo const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
@ -43092,25 +43083,15 @@ namespace VULKAN_HPP_NAMESPACE
|
|||||||
{
|
{
|
||||||
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) && ( pApplicationInfo == rhs.pApplicationInfo ) &&
|
return ( sType == rhs.sType ) && ( pNext == rhs.pNext ) && ( flags == rhs.flags ) && ( pApplicationInfo == rhs.pApplicationInfo ) &&
|
||||||
( enabledLayerCount == rhs.enabledLayerCount ) &&
|
( enabledLayerCount == rhs.enabledLayerCount ) &&
|
||||||
[this, rhs]
|
std::equal( ppEnabledLayerNames,
|
||||||
{
|
ppEnabledLayerNames + enabledLayerCount,
|
||||||
bool equal = true;
|
rhs.ppEnabledLayerNames,
|
||||||
for ( size_t i = 0; equal && ( i < enabledLayerCount ); ++i )
|
[]( char const * left, char const * right ) { return ( left == right ) || ( strcmp( left, right ) == 0 ); } ) &&
|
||||||
{
|
( enabledExtensionCount == rhs.enabledExtensionCount ) &&
|
||||||
equal = ( ( ppEnabledLayerNames[i] == rhs.ppEnabledLayerNames[i] ) || ( strcmp( ppEnabledLayerNames[i], rhs.ppEnabledLayerNames[i] ) == 0 ) );
|
std::equal( ppEnabledExtensionNames,
|
||||||
}
|
ppEnabledExtensionNames + enabledExtensionCount,
|
||||||
return equal;
|
rhs.ppEnabledExtensionNames,
|
||||||
}() && ( enabledExtensionCount == rhs.enabledExtensionCount ) &&
|
[]( char const * left, char const * right ) { return ( left == right ) || ( strcmp( left, right ) == 0 ); } );
|
||||||
[this, rhs]
|
|
||||||
{
|
|
||||||
bool equal = true;
|
|
||||||
for ( size_t i = 0; equal && ( i < enabledExtensionCount ); ++i )
|
|
||||||
{
|
|
||||||
equal = ( ( ppEnabledExtensionNames[i] == rhs.ppEnabledExtensionNames[i] ) ||
|
|
||||||
( strcmp( ppEnabledExtensionNames[i], rhs.ppEnabledExtensionNames[i] ) == 0 ) );
|
|
||||||
}
|
|
||||||
return equal;
|
|
||||||
}();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=( InstanceCreateInfo const & rhs ) const VULKAN_HPP_NOEXCEPT
|
bool operator!=( InstanceCreateInfo const & rhs ) const VULKAN_HPP_NOEXCEPT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user