ATLAS Offline Software
Loading...
Searching...
No Matches
CP::DetailSelectionExprParser::Separator Class Reference

Separator to be used in a boost::tokenizer. More...

#include <SelectionExprParser.h>

Collaboration diagram for CP::DetailSelectionExprParser::Separator:

Public Member Functions

bool operator() (std::string::const_iterator &next, const std::string::const_iterator &end, std::string &tok) const
 Extracts the subsequent token from the input string iterator.
void reset ()
 Optional state reset method, does nothing.

Detailed Description

Separator to be used in a boost::tokenizer.

Definition at line 22 of file SelectionExprParser.h.

Member Function Documentation

◆ operator()()

bool CP::DetailSelectionExprParser::Separator::operator() ( std::string::const_iterator & next,
const std::string::const_iterator & end,
std::string & tok ) const

Extracts the subsequent token from the input string iterator.

Definition at line 21 of file SelectionExprParser.cxx.

23 {
24 if (next == end) {
25 return false;
26 }
27
28 static const std::regex base_regex(
29 "^( ?((?:[^|&()! ]+)|(?:&&)|(?:!)|(?:\\()|(?:\\))|(?:\\|\\|))).*");
30 std::smatch m;
31
32 if (std::regex_match(next, end, m, base_regex)) {
33 tok = m[2].str();
34 next += m[1].length();
35 } else {
36 std::smatch m2;
37 static const std::regex space_re{"^ +$"};
38 if (std::regex_match(next, end, m, space_re)) {
39 // only spaces left, we're done
40 return false;
41 }
42 throw std::runtime_error("Cannot tokenize: '" + std::string(next, end) +
43 "'");
44 }
45 return true;
46}

◆ reset()

void CP::DetailSelectionExprParser::Separator::reset ( )
inline

Optional state reset method, does nothing.

Definition at line 30 of file SelectionExprParser.h.

30{}

The documentation for this class was generated from the following files: