/**************************************************************************** ** Copyright (c) 2021, Fougue Ltd. ** All rights reserved. ** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt ****************************************************************************/ #pragma once #include #include #include namespace Mayo { // Provides meta-data helper functions about enumerated types // Currently it wraps magic_enum 3rdparty library class MetaEnum { public: template static std::string_view name(EnumType enumValue) { return magic_enum::enum_name(enumValue); } template static int count() { return magic_enum::enum_count(); } template static std::string_view nameWithoutPrefix(EnumType enumValue, std::string_view strPrefix) { std::string_view strEnumValueName = MetaEnum::name(enumValue); if (strEnumValueName.find(strPrefix) == 0) return strEnumValueName.substr(strPrefix.size()); else return strEnumValueName; } // Returns std::array with pairs(value, name), sorted by enum value template static auto entries() { return magic_enum::enum_entries(); } template static auto values() { return magic_enum::enum_values(); } }; } // namespace Mayo