@@ -24,39 +24,44 @@ namespace ecf {
2424
2525namespace detail {
2626
27- /* *
28- * EnumTraits defines the mapping between a set of enum values and their designation.
29- *
30- * EnumTraits must define:
31- * - the mapping `map`, provided as a std::array composed of a std::pair<E, const char *> for each enum value
32- * - the `size`, holding the number os entries in `map`
33- *
34- * @tparam E
35- */
36-
27+ // /
28+ // / @brief EnumTraits defines the mapping between a set of enum values and their designation.
29+ // /
30+ // / EnumTraits must define:
31+ // / - the mapping `map`, provided as a std::array composed of a std::pair<E, const char *> for each enum value
32+ // / - the `size`, holding the number of entries in `map`
33+ // /
34+ // / @tparam E the enum type for which the traits are defined
35+ // /
3736template <typename E>
3837struct EnumTraits
3938{
4039};
4140
4241} // namespace detail
4342
43+ // /
44+ // / @brief Enumerate provides bidirectional mapping between enum values and their string designations.
45+ // /
46+ // / @tparam E the enum type to map
47+ // / @tparam TRAITS the traits type providing the mapping; defaults to detail::EnumTraits<E>
48+ // /
4449template <typename E, typename TRAITS = detail::EnumTraits<E>>
4550struct Enumerate
4651{
4752public:
4853 using enum_t = E;
4954 using string_t = std::string_view;
5055
51- /* *
52- * Convert the given enum value to its designation
53- *
54- * This is an "unsafe" operation, as it assumes that the given enum value exists in the mapping.
55- * If the enum value does not exist, an assertion failure is raised.
56- *
57- * @param e the enum value
58- * @return the associated designation
59- * /
56+ // /
57+ // / @brief Convert the given enum value to its designation.
58+ // /
59+ // / This is an "unsafe" operation, as it assumes that the given enum value exists in the mapping.
60+ // / If the enum value does not exist, an assertion failure is raised.
61+ // /
62+ // / @param e the enum value
63+ // / @return the associated designation
64+ // /
6065 static constexpr string_t as_string (enum_t e) noexcept {
6166 auto found = std::find_if (
6267 std::begin (TRAITS ::map), std::end (TRAITS ::map), [&](const auto & item) { return item.first == e; });
@@ -66,12 +71,12 @@ struct Enumerate
6671 return found->second ;
6772 }
6873
69- /* *
70- * Convert the given enum value to its designation
71- *
72- * @param e the enum value
73- * @return the associated designation, in case it exists; an empty optional, otherwise
74- * /
74+ // /
75+ // / @brief Convert the given enum value to its designation.
76+ // /
77+ // / @param e the enum value
78+ // / @return the associated designation, in case it exists; an empty optional, otherwise
79+ // /
7580 static constexpr std::optional<string_t > to_string (enum_t e) noexcept {
7681 if (auto found = std::find_if (
7782 std::begin (TRAITS ::map), std::end (TRAITS ::map), [&](const auto & item) { return item.first == e; });
@@ -82,12 +87,12 @@ struct Enumerate
8287 return std::nullopt ;
8388 }
8489
85- /* *
86- * Convert the given designation to the related enum value
87- *
88- * @param s the designation
89- * @return the enum value, in case it exists; an empty optional, otherwise
90- * /
90+ // /
91+ // / @brief Convert the given designation to the related enum value.
92+ // /
93+ // / @param s the designation
94+ // / @return the enum value, in case it exists; an empty optional, otherwise
95+ // /
9196 static constexpr std::optional<E> to_enum (string_t s) noexcept {
9297 if (auto found = std::find_if (
9398 std::begin (TRAITS ::map), std::end (TRAITS ::map), [&](const auto & item) { return item.second == s; });
@@ -98,26 +103,28 @@ struct Enumerate
98103 return std::nullopt ;
99104 }
100105
101- /* *
102- * Checks if the given designation is valid (i.e. has a related enum value)
103- *
104- * @param s the designation
105- * @return true, if valid; false, otherwise
106- * /
106+ // /
107+ // / @brief Check if the given designation is valid (i.e. has a related enum value).
108+ // /
109+ // / @param s the designation
110+ // / @return true, if valid; false, otherwise
111+ // /
107112 static constexpr bool is_valid (string_t s) {
108113 auto found = std::find_if (
109114 std::begin (TRAITS ::map), std::end (TRAITS ::map), [&](const auto & item) { return item.second == s; });
110115 return found != std::end (TRAITS ::map);
111116 }
112117
113- /* *
114- * The number of mapped enum values
115- * /
118+ // /
119+ // / @brief The number of mapped enum values.
120+ // /
116121 static const size_t size = TRAITS ::size;
117122
118- /* *
119- * The vector of mapped enum values
120- */
123+ // /
124+ // / @brief Collect all mapped enum values.
125+ // /
126+ // / @return a vector containing all mapped enum values
127+ // /
121128 static auto enums () {
122129 std::vector<E> result;
123130 result.reserve (TRAITS ::size);
@@ -128,9 +135,11 @@ struct Enumerate
128135 return result;
129136 }
130137
131- /* *
132- * The vector of mapped designations
133- */
138+ // /
139+ // / @brief Collect all mapped designations.
140+ // /
141+ // / @return a vector containing all mapped designations
142+ // /
134143 static auto designations () {
135144 std::vector<std::string> result;
136145 result.reserve (TRAITS ::size);
0 commit comments