From f0c41645153d0cedacb93ed53c0543849cfd9dc4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 11 Aug 2020 20:49:57 +0200 Subject: [PATCH] [libcalamares] Add a more convenient find() to NamedEnum - In most cases, you **know** the table covers all the enum values, and the extra parameter *ok* is just annoying. Provide a convenience that doesn't distinguish empty from empty-but-valid. --- src/libcalamares/utils/NamedEnum.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libcalamares/utils/NamedEnum.h b/src/libcalamares/utils/NamedEnum.h index bf8ff5d18..d962b3c76 100644 --- a/src/libcalamares/utils/NamedEnum.h +++ b/src/libcalamares/utils/NamedEnum.h @@ -105,6 +105,16 @@ struct NamedEnumTable // ok is still false return string_t(); } + + /** @brief Find a value @p s in the table and return its name. + * + * Returns emptry string if the value is not found. + */ + string_t find( enum_t s ) const + { + bool ok = false; + return find( s, ok ); + } }; /** @brief Smashes an enum value to its underlying type. */