CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
cutParser.cc
Go to the documentation of this file.
5 
6 using namespace reco::parser;
7 bool reco::parser::cutParser(const Reflex::Type &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 != ' ') { justBlanks = false; break; }
11  }
12  if(justBlanks) {
13  sel = SelectorPtr(new AnyObjSelector);
14  return true;
15  } else {
16  using namespace boost::spirit::classic;
17  Grammar grammar(sel, t, lazy);
18  bool returnValue = false;
19  const char* startingFrom =cut.c_str();
20  try {
21  returnValue = parse(startingFrom, grammar.use_parser<0>() >> end_p, space_p).full;
22  }
23  catch(BaseException& e) {
24  throw edm::Exception(edm::errors::Configuration)<<"Cut parser error:"<<baseExceptionWhat(e)<<" (char "<<e.where-startingFrom<<")\n";
25  }
26  return returnValue;
27  }
28 }
29 
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:37
Evaluator * parse(const T &text)
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate &#39;what&#39; message for the exception
Definition: Exception.h:40
tuple cut
Definition: align_tpl.py:88
boost::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:17
bool cutParser(const Reflex::Type &t, const std::string &cut, SelectorPtr &sel, bool lazy)
Definition: cutParser.cc:7