Belle II Software development
StringFormulaConstructor Struct Reference

Example struct to be used with the FormulaParser to create a string representation of the formula, mainly for testing and debugging. More...

#include <FormulaParser.h>

Public Types

typedef std::string type
 Create strings as output of FormulaParser.
 
typedef FormulaParserBase::EOperator Op
 Shorthand for the operator enum.
 

Public Member Functions

type operator() (const std::string &name)
 Create output type from a string identifier: let's quote it.
 
type operator() (double value)
 Create output type from a double: just convert to string.
 
type operator() (Op op, const type &a, const type &b)
 Apply operator to two output types: just add brackets and operator.
 
type operator() (Op op, double a, const type &b)
 Apply operator to double and output type.
 
type operator() (Op op, const type &a, double b)
 Apply operator to output type and double.
 

Detailed Description

Example struct to be used with the FormulaParser to create a string representation of the formula, mainly for testing and debugging.

Definition at line 203 of file FormulaParser.h.

Member Typedef Documentation

◆ Op

Shorthand for the operator enum.

Definition at line 207 of file FormulaParser.h.

◆ type

typedef std::string type

Create strings as output of FormulaParser.

Definition at line 205 of file FormulaParser.h.

Member Function Documentation

◆ operator()() [1/5]

type operator() ( const std::string &  name)
inline

Create output type from a string identifier: let's quote it.

Definition at line 210 of file FormulaParser.h.

210{ return "'" + name + "'"; }

◆ operator()() [2/5]

type operator() ( double  value)
inline

Create output type from a double: just convert to string.

Definition at line 212 of file FormulaParser.h.

212{ return std::to_string(value); }

◆ operator()() [3/5]

type operator() ( Op  op,
const type a,
const type b 
)
inline

Apply operator to two output types: just add brackets and operator.

Definition at line 214 of file FormulaParser.h.

215 {
216 return "(" + a + FormulaParserBase::operatorToChar(op) + b + ")";
217 }
static char operatorToChar(EOperator op) noexcept
Convert operator code to character.

◆ operator()() [4/5]

type operator() ( Op  op,
const type a,
double  b 
)
inline

Apply operator to output type and double.

Definition at line 221 of file FormulaParser.h.

221{ return (*this)(op, a, std::to_string(b)); }

◆ operator()() [5/5]

type operator() ( Op  op,
double  a,
const type b 
)
inline

Apply operator to double and output type.

Definition at line 219 of file FormulaParser.h.

219{ return (*this)(op, std::to_string(a), b); }

The documentation for this struct was generated from the following file: