Merge pull request #807 from asuessenbach/toHexString

Introduce helper function toHexString used in to_string functions on invalid values.
This commit is contained in:
Andreas Süßenbach 2020-10-27 12:30:27 +01:00 committed by GitHub
commit cf92bfea25
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 186 additions and 167 deletions

View File

@ -2222,6 +2222,16 @@ void VulkanHppGenerator::appendEnum( std::string & str, std::pair<std::string, E
void VulkanHppGenerator::appendEnums( std::string & str ) const void VulkanHppGenerator::appendEnums( std::string & str ) const
{ {
// start with toHexString, which is used in all the to_string functions here!
str += R"(
VULKAN_HPP_INLINE std::string toHexString( uint32_t value )
{
std::stringstream stream;
stream << std::hex << value;
return stream.str();
}
)";
for ( auto const & e : m_enums ) for ( auto const & e : m_enums )
{ {
std::string enter, leave; std::string enter, leave;
@ -2297,7 +2307,7 @@ void VulkanHppGenerator::appendEnumToString( std::string &
str += " case " + enumName + "::" + value.vkValue + " : return \"" + value.vkValue.substr( 1 ) + "\";\n"; str += " case " + enumName + "::" + value.vkValue + " : return \"" + value.vkValue.substr( 1 ) + "\";\n";
} }
str += str +=
" default: return \"invalid\";\n" " default: return \"invalid ( \" + VULKAN_HPP_NAMESPACE::toHexString( static_cast<uint32_t>( value ) ) + \" )\";\n"
" }\n"; " }\n";
} }
@ -10622,6 +10632,7 @@ int main( int argc, char ** argv )
#include <cstring> #include <cstring>
#include <functional> #include <functional>
#include <initializer_list> #include <initializer_list>
#include <sstream>
#include <string> #include <string>
#include <system_error> #include <system_error>
#include <tuple> #include <tuple>

File diff suppressed because it is too large Load Diff