CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 Reflex, useless. More...
 

Static Public Member Functions

static Reflex::Type elementType (const Reflex::Type &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 Reflex::Type type, const void *obj)
 Make a Reflex::Object(type, obj) and pass it to the expression. More...
 
static reco::parser::ExpressionPtr makeExpression (const std::string &expr, const Reflex::Type &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 Reflex::Type &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 Reflex::Type type, const void *obj)
 Make a Reflex::Object(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 Reflex 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 Reflex, useless.

Definition at line 27 of file ScannerHelpers.h.

27 {}

Member Function Documentation

Reflex::Type helper::Parser::elementType ( const Reflex::Type &  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 dtNoiseDBValidation_cfg::cerr, runEdmFileComparison::collection, and i.

Referenced by fwlite::Scanner< Collection >::Scanner().

39  {
40  Reflex::Type collection = wrapperType.TemplateArgumentAt(0);
41  while (collection.IsTypedef()) collection = collection.ToType();
42  // now search for value_type
43  for (size_t i = 0; i < collection.SubTypeSize(); ++i) {
44  Reflex::Type objtype = collection.SubTypeAt(i);
45  if (objtype.Name() == "value_type") {
46  while (objtype.IsTypedef()) objtype = objtype.ToType();
47  return objtype;
48  }
49  }
50  std::cerr << "Can't get a type out of " << wrapperType.Name(Reflex::SCOPED) << std::endl;
51  return Reflex::Type();
52 }
int i
Definition: DBlmapReader.cc:9
double helper::Parser::eval ( const reco::parser::ExpressionPtr sel,
const Reflex::Type  type,
const void *  obj 
)
static

Make a Reflex::Object(type, obj) and pass it to the expression.

Definition at line 61 of file ScannerHelpers.cc.

References getGTfromDQMFile::obj.

61  {
62  if (expr.get() == 0) return 0;
63  Reflex::Object obj(type, const_cast<void *>(ptr));
64  return expr->value(obj);
65 }
type
Definition: HCALResponse.h:22
reco::parser::ExpressionPtr helper::Parser::makeExpression ( const std::string &  expr,
const Reflex::Type &  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(), dtNoiseDBValidation_cfg::cerr, alignCSCRings::e, triggerExpression::parse(), and run_regression::ret.

Referenced by helper::ScannerBase::addExpression().

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).full;
18  std::cerr << "Expression parser error:"<<reco::parser::baseExceptionWhat(e)<<" (char "<<e.where-startingFrom<<")" << std::endl;
19  }
20  return ret;
21 }
type
Definition: HCALResponse.h:22
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:37
Evaluator * parse(const T &text)
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
reco::parser::SelectorPtr helper::Parser::makeSelector ( const std::string &  expr,
const Reflex::Type &  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(), dtNoiseDBValidation_cfg::cerr, alignCSCRings::e, triggerExpression::parse(), and run_regression::ret.

Referenced by helper::ScannerBase::addExtraCut(), 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).full;
33  std::cerr << "Selector parser error:"<<reco::parser::baseExceptionWhat(e)<<" (char "<<e.where-startingFrom<<")" << std::endl;
34  }
35  return ret;
36 }
type
Definition: HCALResponse.h:22
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
boost::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:17
bool helper::Parser::test ( const reco::parser::SelectorPtr sel,
const Reflex::Type  type,
const void *  obj 
)
static

Make a Reflex::Object(type, obj) and pass it to the selector.

Definition at line 55 of file ScannerHelpers.cc.

References getGTfromDQMFile::obj.

55  {
56  if (sel.get() == 0) return false;Reflex::Object obj(type, const_cast<void *>(ptr));
57  return (*sel)(obj);
58 }
type
Definition: HCALResponse.h:22