CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions
helper::Parser Class Reference

#include <ScannerHelpers.h>

Public Member Functions

 Parser ()
 Empty constructor, necessary for Root, useless. More...
 

Static Public Member Functions

static edm::TypeWithDict elementType (const edm::TypeWithDict &wrapperType)
 Perform the type deduction form edm::Wrapper<C> to C::value_type and resolves typedefs. More...
 
static double eval (const reco::parser::ExpressionPtr &sel, const edm::TypeWithDict type, const void *obj)
 Make a edm::ObjectWithDict(type, obj) and pass it to the expression. More...
 
static reco::parser::ExpressionPtr makeExpression (const std::string &expr, const edm::TypeWithDict &type)
 Parse an expression for a given object type (using lazy parsing when resolving methods) More...
 
static reco::parser::SelectorPtr makeSelector (const std::string &expr, const edm::TypeWithDict &type)
 Parse an expression for a given object type (using lazy parsing when resolving methods) More...
 
static bool test (const reco::parser::SelectorPtr &sel, const edm::TypeWithDict type, const void *obj)
 Make a edm::ObjectWithDict(type, obj) and pass it to the selector. More...
 

Detailed Description

Class helper::Parser has collection of useful static methods related to StringParser that can be exported to CINT via dictionaries. It's mosly meant to be used through the helper::ScannerBase class.

Definition at line 24 of file ScannerHelpers.h.

Constructor & Destructor Documentation

helper::Parser::Parser ( )
inline

Empty constructor, necessary for Root, useless.

Definition at line 27 of file ScannerHelpers.h.

References elementType(), eval(), jets_cff::expr, makeExpression(), makeSelector(), MuonAssociatorByHits_cfi::obj, triggerObjects_cff::sel, AlCaHLTBitMon_QueryRunRegistry::string, and test().

27 {}

Member Function Documentation

edm::TypeWithDict helper::Parser::elementType ( const edm::TypeWithDict wrapperType)
static

Perform the type deduction form edm::Wrapper<C> to C::value_type and resolves typedefs.

Definition at line 39 of file ScannerHelpers.cc.

References MessageLogger_cfi::cerr, mps_alisetup::collection, edm::TypeWithDict::name(), edm::TypeWithDict::nestedType(), and edm::TypeWithDict::templateArgumentAt().

Referenced by Parser(), and fwlite::Scanner< Collection >::Scanner().

39  {
41  // now search for value_type
42  edm::TypeWithDict objtype = collection.nestedType("value_type");
43  if(bool(objtype)) {
44  return objtype;
45  }
46  std::cerr << "Can't get a type out of " << wrapperType.name() << std::endl;
47  return edm::TypeWithDict();
48 }
TypeWithDict nestedType(char const *) const
TypeWithDict templateArgumentAt(size_t index) const
std::string name() const
double helper::Parser::eval ( const reco::parser::ExpressionPtr sel,
const edm::TypeWithDict  type,
const void *  obj 
)
static

Make a edm::ObjectWithDict(type, obj) and pass it to the expression.

Definition at line 58 of file ScannerHelpers.cc.

References MuonAssociatorByHits_cfi::obj.

Referenced by helper::ScannerBase::numberOfExtraCuts(), and Parser().

58  {
59  if (expr.get() == 0) return 0;
60  edm::ObjectWithDict obj(type, const_cast<void *>(ptr));
61  return expr->value(obj);
62 }
reco::parser::ExpressionPtr helper::Parser::makeExpression ( const std::string &  expr,
const edm::TypeWithDict type 
)
static

Parse an expression for a given object type (using lazy parsing when resolving methods)

NOTA BENE: <0> for cuts, <1> for expresions (why? boh!)

Definition at line 9 of file ScannerHelpers.cc.

References reco::parser::baseExceptionWhat(), MessageLogger_cfi::cerr, MillePedeFileConverter_cfg::e, and dumpparser::parse().

Referenced by helper::ScannerBase::addExpression(), and Parser().

9  {
11 
12  using namespace boost::spirit::classic;
13  reco::parser::Grammar grammar(ret, type, true);
14  const char* startingFrom = expr.c_str();
15  try {
16  parse(startingFrom, grammar.use_parser<1>() >> end_p, space_p);
18  std::cerr << "Expression parser error:"<<reco::parser::baseExceptionWhat(e)<<" (char "<<e.where-startingFrom<<")" << std::endl;
19  }
20  return ret;
21 }
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:37
boost::shared_ptr< ExpressionBase > ExpressionPtr
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate &#39;what&#39; message for the exception
Definition: Exception.h:40
def parse(path, config)
Definition: dumpparser.py:13
reco::parser::SelectorPtr helper::Parser::makeSelector ( const std::string &  expr,
const edm::TypeWithDict type 
)
static

Parse an expression for a given object type (using lazy parsing when resolving methods)

NOTA BENE: <0> for cuts, <1> for expresions (why? boh!)

Definition at line 24 of file ScannerHelpers.cc.

References reco::parser::baseExceptionWhat(), MessageLogger_cfi::cerr, MillePedeFileConverter_cfg::e, and dumpparser::parse().

Referenced by helper::ScannerBase::addExtraCut(), Parser(), and helper::ScannerBase::setCut().

24  {
26 
27  using namespace boost::spirit::classic;
28  reco::parser::Grammar grammar(ret, type, true);
29  const char* startingFrom = expr.c_str();
30  try {
31  parse(startingFrom, grammar.use_parser<0>() >> end_p, space_p);
33  std::cerr << "Selector parser error:"<<reco::parser::baseExceptionWhat(e)<<" (char "<<e.where-startingFrom<<")" << std::endl;
34  }
35  return ret;
36 }
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
def parse(path, config)
Definition: dumpparser.py:13
boost::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:17
bool helper::Parser::test ( const reco::parser::SelectorPtr sel,
const edm::TypeWithDict  type,
const void *  obj 
)
static