9#include <framework/utilities/NumberSequence.h>
23 std::vector<std::string> tokens;
24 unsigned int lastdelimiter = 0;
25 for (
unsigned int i = 0; i < str.size(); ++i) {
27 tokens.push_back(str.substr(lastdelimiter, i - lastdelimiter));
28 lastdelimiter = i + 1;
31 std::string last = str.substr(lastdelimiter);
32 if (last.size() != 0) {
33 tokens.push_back(last);
37 std::vector<std::pair<int64_t, int64_t>> intervals;
38 intervals.reserve(tokens.size());
39 for (
const auto& token : tokens) {
40 size_t interval_marker_position = token.find(
':');
42 if (interval_marker_position == std::string::npos) {
43 int64_t number = std::stol(token);
44 intervals.emplace_back(number, number);
46 int64_t interval_begin = std::stol(token.substr(0, interval_marker_position));
47 int64_t interval_end = std::stol(token.substr(interval_marker_position + 1));
48 intervals.emplace_back(interval_begin, interval_end);
53 std::set<int64_t> sequence;
54 for (
const auto& interval : intervals) {
55 for (int64_t number = interval.first; number <= interval.second; ++number)
56 sequence.insert(number);
std::set< int64_t > generate_number_sequence(const std::string &str)
Generate a sequence of numbers defined by a string.
Abstract base class for different kinds of events.