1#ifndef RANGE_PARSER_DEFINED
2#define RANGE_PARSER_DEFINED
31 std::vector<int> range;
33 int dash_pos(atomicRange.find(
"-"));
35 low = std::stoi(atomicRange);
38 low = std::stoi(atomicRange.substr(0, dash_pos));
39 high = std::stoi(atomicRange.substr(dash_pos + 1,
40 atomicRange.length() - dash_pos - 1));
43 LOG(1,
"Parser") <<
"Low " << low << std::endl;
44 LOG(1,
"Parser") <<
"high " << high << std::endl;
46 for (
int i(std::min(low, high)); i <= std::max(low, high); i++) {
61 char comma =
',', space =
' ';
62 for (
unsigned int i(0); i <
rawRange.length(); i++) {
68 if (i !=
rawRange.length() - 1) {
continue; }
84 for (
const auto &i : parser.
getRange()) stream << i <<
" ";
std::ostream & operator<<(std::ostream &s, const FcidumpReader::FcidumpHeader &h)
Definition FcidumpWriter.cxx:25
#define LOG(...)
Definition Log.hpp:119
Class to parse a string of comma separated range delimiters. Note: It only works for unsigned integer...
Definition RangeParser.hpp:10
std::vector< int > getRange() const
Get the range in the form of a vector of integers.
Definition RangeParser.hpp:23
RangeParser(const std::string &rawRange_)
Constructor from a string, it will parse the string automatically.
Definition RangeParser.hpp:16
void parse()
Main parser method, it will parse a comma separated string of range delimiters.
Definition RangeParser.hpp:59
const std::string rawRange
Definition RangeParser.hpp:78
std::vector< int > parsedRange
Definition RangeParser.hpp:79
std::vector< int > atomicRangeToRange(const std::string &atomicRange)
Parse individual range atoms. For example this method will map "2" into std::vector<int>{2} and "2-3"...
Definition RangeParser.hpp:30
Definition Algorithm.hpp:10