/**************************************************************************** ** Copyright (c) 2021, Fougue Ltd. ** All rights reserved. ** See license at https://github.com/fougue/mayo/blob/master/LICENSE.txt ****************************************************************************/ #pragma once #include "enumeration.h" #include "meta_enum.h" // -- // -- Implementation of template function Enumeration::fromType() // -- namespace Mayo { template struct EnumNames { static inline const std::string_view trContext = ""; static inline const std::string_view junkPrefix = ""; }; template Enumeration Enumeration::fromType() { const bool hasJunkPrefix = !EnumNames::junkPrefix.empty(); Enumeration enumObject; for (const EnumType value : MetaEnum::values()) { std::string_view key = hasJunkPrefix ? MetaEnum::nameWithoutPrefix(value, EnumNames::junkPrefix) : MetaEnum::name(value); const TextId keyTextId = { EnumNames::trContext, key }; enumObject.addItem(int(value), keyTextId); } return enumObject; } } // namespace Mayo