22
33#include < cstdint>
44#include < string>
5+ #include < string_view>
56#include < set>
67#include < regex>
78#include < string>
8- #include < utility>
99#include < vector>
1010#include < array>
1111#include < span>
12- #include < utility>
12+ #include < type_traits>
13+ #include < iterator>
1314
1415#include < oryx/chron/time_types.hpp>
1516#include < oryx/chron/details/string_split.hpp>
1617#include < oryx/chron/details/ctre.hpp>
1718#include < oryx/chron/details/string_cast.hpp>
19+ #include < oryx/chron/details/to_underlying.hpp>
1820
1921namespace oryx ::chron {
2022
@@ -101,7 +103,7 @@ template <typename T>
101103auto Data::ValidateLiteral (const std::string& s, std::set<T>& numbers, std::span<const std::string_view> names)
102104 -> bool {
103105 auto parts = details::StringSplit (s, ' ,' );
104- auto value_of_first_name = std ::to_underlying (T::First);
106+ auto value_of_first_name = details ::to_underlying (T::First);
105107
106108 for (auto & name : names) {
107109 std::regex regex_pattern (name.data (), std::regex_constants::ECMAScript | std::regex_constants::icase);
@@ -145,7 +147,7 @@ template <typename T>
145147auto Data::GetStep (std::string_view s, uint8_t & start, uint8_t & step) -> bool {
146148 if (auto match = ctre::match<R"#( (\d+|\*)/(\d+))#" >(s)) {
147149 auto first = match.get <1 >().to_view ();
148- int raw_start = (first == " *" ) ? std ::to_underlying (T::First) : details::StringCast<int >(first);
150+ int raw_start = (first == " *" ) ? details ::to_underlying (T::First) : details::StringCast<int >(first);
149151 int raw_step = details::StringCast<int >(match.get <2 >().to_view ());
150152 if (IsWithinLimits<T>(raw_start, raw_start) && raw_step > 0 ) {
151153 start = static_cast <uint8_t >(raw_start);
@@ -158,7 +160,7 @@ auto Data::GetStep(std::string_view s, uint8_t& start, uint8_t& step) -> bool {
158160
159161template <typename T>
160162auto Data::AddFullRange (std::set<T>& set) -> void {
161- for (auto v = std ::to_underlying (T::First); v <= std ::to_underlying (T::Last); ++v) {
163+ for (auto v = details ::to_underlying (T::First); v <= details ::to_underlying (T::Last); ++v) {
162164 if (set.find (static_cast <T>(v)) == set.end ()) {
163165 set.emplace (static_cast <T>(v));
164166 }
@@ -175,8 +177,8 @@ auto Data::AddNumber(std::set<T>& set, int32_t number) -> bool {
175177
176178template <typename T>
177179auto Data::IsWithinLimits (int32_t low, int32_t high) -> bool {
178- return IsBetween (low, std ::to_underlying (T::First), std ::to_underlying (T::Last)) &&
179- IsBetween (high, std ::to_underlying (T::First), std ::to_underlying (T::Last));
180+ return IsBetween (low, details ::to_underlying (T::First), details ::to_underlying (T::Last)) &&
181+ IsBetween (high, details ::to_underlying (T::First), details ::to_underlying (T::Last));
180182}
181183
182184template <typename T>
@@ -191,19 +193,19 @@ auto Data::ConvertFromStringRangeToNumberRange(std::string_view range, std::set<
191193 result = AddNumber<T>(numbers, details::StringCast<int32_t >(range));
192194 } else if (GetRange<T>(range, left, right)) {
193195 if (left <= right) {
194- for (auto v = std ::to_underlying (left); v <= std ::to_underlying (right); ++v) {
196+ for (auto v = details ::to_underlying (left); v <= details ::to_underlying (right); ++v) {
195197 result &= AddNumber (numbers, v);
196198 }
197199 } else {
198- for (auto v = std ::to_underlying (left); v <= std ::to_underlying (T::Last); ++v) {
200+ for (auto v = details ::to_underlying (left); v <= details ::to_underlying (T::Last); ++v) {
199201 result &= AddNumber (numbers, v);
200202 }
201- for (auto v = std ::to_underlying (T::First); v <= std ::to_underlying (right); ++v) {
203+ for (auto v = details ::to_underlying (T::First); v <= details ::to_underlying (right); ++v) {
202204 result &= AddNumber (numbers, v);
203205 }
204206 }
205207 } else if (GetStep<T>(range, step_start, step)) {
206- for (auto v = step_start; v <= std ::to_underlying (T::Last); v += step) {
208+ for (auto v = step_start; v <= details ::to_underlying (T::Last); v += step) {
207209 result &= AddNumber (numbers, v);
208210 }
209211 } else {
@@ -216,7 +218,7 @@ auto Data::ConvertFromStringRangeToNumberRange(std::string_view range, std::set<
216218template <typename T>
217219 requires (std::is_same_v<T, Months> || std::is_same_v<T, DayOfWeek>)
218220auto Data::ReplaceStringNameWithNumeric (std::string& s) -> std::string& {
219- auto value = std ::to_underlying (T::First);
221+ auto value = details ::to_underlying (T::First);
220222
221223 if constexpr (std::is_same_v<T, Months>) {
222224 for (auto name : kMonthNames ) {
0 commit comments