1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:47:35 +00:00

LibTLS: Show enum value instead of underlying value where possible

This commit is contained in:
stelar7 2023-04-14 00:45:32 +02:00 committed by Sam Atkins
parent 5853d9642a
commit 9059694216
4 changed files with 93 additions and 10 deletions

View file

@ -704,6 +704,89 @@ enum class AlertDescription : u8 {
#undef _ENUM_KEY
#undef _ENUM_KEY_VALUE
constexpr static StringView enum_to_string(CipherSuite descriptor)
{
#define _ENUM_KEY_VALUE(name, value) \
case CipherSuite::name: \
return #name##sv;
switch (descriptor) {
__ENUM_CIPHER_SUITES
}
return "Unknown"sv;
#undef _ENUM_KEY_VALUE
}
constexpr static StringView enum_to_string(ExtensionType descriptor)
{
#define _ENUM_KEY_VALUE(name, value) \
case ExtensionType::name: \
return #name##sv;
switch (descriptor) {
__ENUM_EXTENSION_TYPES
}
return "Unknown"sv;
#undef _ENUM_KEY_VALUE
}
constexpr static StringView enum_to_string(ContentType descriptor)
{
#define _ENUM_KEY_VALUE(name, value) \
case ContentType::name: \
return #name##sv;
switch (descriptor) {
__ENUM_CONTENT_TYPES
}
return "Unknown"sv;
#undef _ENUM_KEY_VALUE
}
constexpr static StringView enum_to_string(ProtocolVersion descriptor)
{
#define _ENUM_KEY_VALUE(name, value) \
case ProtocolVersion::name: \
return #name##sv;
switch (descriptor) {
__ENUM_PROTOCOL_VERSIONS
}
return "Unknown"sv;
#undef _ENUM_KEY_VALUE
}
constexpr static StringView enum_to_string(HandshakeType descriptor)
{
#define _ENUM_KEY_VALUE(name, value) \
case HandshakeType::name: \
return #name##sv;
switch (descriptor) {
__ENUM_HANDSHAKE_TYPES
}
return "Unknown"sv;
#undef _ENUM_KEY_VALUE
}
constexpr static StringView enum_to_string(SignatureAlgorithm descriptor)
{
#define _ENUM_KEY_VALUE(name, value) \
case SignatureAlgorithm::name: \
return #name##sv;
switch (descriptor) {
__ENUM_SIGNATURE_ALGORITHM
}
return "Unknown"sv;
#undef _ENUM_KEY_VALUE
}
constexpr static StringView enum_to_string(AlertDescription descriptor)
{
#define _ENUM_KEY_VALUE(name, value) \