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 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 != ' ') { 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 
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:37
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate &#39;what&#39; message for the exception
Definition: Exception.h:40
boost::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:17