CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cutParser.cc
Go to the documentation of this file.
5 
6 using namespace reco::parser;
7 bool reco::parser::cutParser(const edm::TypeWithDict& t, const std::string& cut, SelectorPtr& sel, bool lazy = false) {
8  bool justBlanks = true;
9  for (std::string::const_iterator c = cut.begin(); c != cut.end(); ++c) {
10  if (*c != ' ') {
11  justBlanks = false;
12  break;
13  }
14  }
15  if (justBlanks) {
16  sel = SelectorPtr(new AnyObjSelector);
17  return true;
18  } else {
19  using namespace boost::spirit::classic;
20  Grammar grammar(sel, t, lazy);
21  bool returnValue = false;
22  const char* startingFrom = cut.c_str();
23  try {
24  returnValue = parse(startingFrom, grammar.use_parser<0>() >> end_p, space_p).full;
25  } catch (BaseException& e) {
27  << "Cut parser error:" << baseExceptionWhat(e) << " (char " << e.where - startingFrom << ")\n"
28  << "Cut string was " << cut;
29  }
30  return returnValue;
31  }
32 }
const edm::EventSetup & c
bool cutParser(const edm::TypeWithDict &t, const std::string &cut, SelectorPtr &sel, bool lazy)
Definition: cutParser.cc:7
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:33
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate &#39;what&#39; message for the exception
Definition: Exception.h:36
std::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:18