mirror of
https://github.com/PerMalmberg/libcron.git
synced 2025-04-22 08:23:04 -05:00
Don't need to pass the offset, it can be derived from T::First.
This commit is contained in:
parent
c74c4b8c3c
commit
d19de56b4f
@ -31,8 +31,8 @@ namespace libcron
|
|||||||
valid &= validate_numeric<Minutes>(match[2], minutes);
|
valid &= validate_numeric<Minutes>(match[2], minutes);
|
||||||
valid &= validate_numeric<Hours>(match[3], hours);
|
valid &= validate_numeric<Hours>(match[3], hours);
|
||||||
valid &= validate_numeric<DayOfMonth>(match[4], day_of_month);
|
valid &= validate_numeric<DayOfMonth>(match[4], day_of_month);
|
||||||
valid &= validate_literal<Months>(match[5], months, month_names, 1);
|
valid &= validate_literal<Months>(match[5], months, month_names);
|
||||||
valid &= validate_literal<DayOfWeek>(match[6], day_of_week, day_names, 0);
|
valid &= validate_literal<DayOfWeek>(match[6], day_of_week, day_names);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +81,7 @@ namespace libcron
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
bool validate_literal(const std::string& s,
|
bool validate_literal(const std::string& s,
|
||||||
std::set<T>& numbers,
|
std::set<T>& numbers,
|
||||||
const std::vector<std::string>& names,
|
const std::vector<std::string>& names);
|
||||||
int32_t name_offset);
|
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
bool process_parts(const std::vector<std::string>& parts, std::set<T>& numbers);
|
bool process_parts(const std::vector<std::string>& parts, std::set<T>& numbers);
|
||||||
@ -138,11 +137,12 @@ namespace libcron
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
bool CronTime::validate_literal(const std::string& s,
|
bool CronTime::validate_literal(const std::string& s,
|
||||||
std::set<T>& numbers,
|
std::set<T>& numbers,
|
||||||
const std::vector<std::string>& names,
|
const std::vector<std::string>& names)
|
||||||
int32_t name_offset)
|
|
||||||
{
|
{
|
||||||
std::vector<std::string> parts = split(s, ',');
|
std::vector<std::string> parts = split(s, ',');
|
||||||
|
|
||||||
|
auto value_of_first_name = value_of(T::First);
|
||||||
|
|
||||||
// Replace each found name with the corresponding value.
|
// Replace each found name with the corresponding value.
|
||||||
for (const auto& name : names)
|
for (const auto& name : names)
|
||||||
{
|
{
|
||||||
@ -151,12 +151,12 @@ namespace libcron
|
|||||||
{
|
{
|
||||||
std::string replaced;
|
std::string replaced;
|
||||||
std::regex_replace(std::back_inserter(replaced), parts[i].begin(), parts[i].end(), m,
|
std::regex_replace(std::back_inserter(replaced), parts[i].begin(), parts[i].end(), m,
|
||||||
std::to_string(name_offset));
|
std::to_string(value_of_first_name));
|
||||||
|
|
||||||
parts[i] = replaced;
|
parts[i] = replaced;
|
||||||
}
|
}
|
||||||
|
|
||||||
name_offset++;
|
value_of_first_name++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return process_parts(parts, numbers);
|
return process_parts(parts, numbers);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user