ionflux.org | Impressum

Ionflux::Tools::TreeEval Class Reference
[Data handling]

Tree expression evaluator. More...

#include <TreeEval.hpp>

Collaboration diagram for Ionflux::Tools::TreeEval:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TreeEval ()
 Constructor.
virtual ~TreeEval ()
 Destructor.

Static Public Member Functions

static bool parseTreeExpr (const std::string &treeExpr, std::vector< TreeExprElement > &elements)
 Parse tree expression.
static bool eval (Tree *tree, std::vector< TreeExprElement > &elements, Node &result, bool createPath)
 Evaluate tree expression.

Static Public Attributes

static const TokenType TT_OPERATOR
 Token type: Operators.
static const TokenType TT_TREEPATH_NP
 Token type: Tree path (excluding parentheses).
static const TokenType TT_PAR_LEFT
 Token type: Parenthesis (left).
static const TokenType TT_PAR_RIGHT
 Token type: Parenthesis (right).

Static Protected Member Functions

static bool calculate (DataEntry &op1, DataEntry &result, const std::string &op)
 Perform calculation.
static bool calculate (DataEntry &op1, DataEntry &op2, DataEntry &result, const std::string &op)
 Perform calculation.
static bool unwindOpStack (std::stack< TreeExprElement > &ops, std::stack< TreeExprElement > &values, Tree &temps, bool unwindPar=false)
 Unwind operator stack.

Detailed Description

Tree expression evaluator.

Evaluates expressions in which tree paths are used as variables.


Constructor & Destructor Documentation

Ionflux::Tools::TreeEval::TreeEval  ) 
 

Constructor.

Construct new TreeEval object.

Ionflux::Tools::TreeEval::~TreeEval  )  [virtual]
 

Destructor.

Destruct TreeEval object.


Member Function Documentation

bool Ionflux::Tools::TreeEval::calculate DataEntry op1,
DataEntry op2,
DataEntry result,
const std::string &  op
[static, protected]
 

Perform calculation.

Performs a calculation using the specified binary operator.

Parameters:
op1 First operand.
op2 Second operand.
result Data entry to store the result in.
op Unary operator.
Returns:
true on success, false if there was an error.

bool Ionflux::Tools::TreeEval::calculate DataEntry op1,
DataEntry result,
const std::string &  op
[static, protected]
 

Perform calculation.

Performs a calculation using the specified unary operator.

Parameters:
op1 Operand.
result Data entry to store the result in.
op Unary operator.
Returns:
true on success, false if there was an error.

bool Ionflux::Tools::TreeEval::eval Tree tree,
std::vector< TreeExprElement > &  elements,
Node result,
bool  createPath
[static]
 

Evaluate tree expression.

Evaluates a tree expression for a specified tree and a set of tree expression elements. Pass true to createPath to create tree paths on the fly if it they do not already exist.

Parameters:
tree Tree for which the expression should be evaluated.
elements Tree expression elements to evaluate.
result Where to store the result of the evaluation.
createPath Whether to create a path if it does not already exist.
Returns:
true on success, false if there was an error.

bool Ionflux::Tools::TreeEval::parseTreeExpr const std::string &  treeExpr,
std::vector< TreeExprElement > &  elements
[static]
 

Parse tree expression.

Parse a tree expression into tree expression elements.

Parameters:
treeExpr Tree expression.
elements Vector in which to store tree expression elements.
Returns:
true on success, false if there was an error.

bool Ionflux::Tools::TreeEval::unwindOpStack std::stack< TreeExprElement > &  ops,
std::stack< TreeExprElement > &  values,
Tree temps,
bool  unwindPar = false
[static, protected]
 

Unwind operator stack.

Unwinds an operator stack by processing the topmost element, or all operators until either the stack is empty or a left parenthesis is found. The result of the operation is put on top of the value stack.

Parameters:
ops Operator stack.
values Value stack.
temps Tree in which to store temporary values.
unwindPar Whether to unwind the stack until it is empty or a left parenthesis is found.
Returns:
true on success, false if there was an error.


Member Data Documentation

const TokenType Ionflux::Tools::TreeEval::TT_OPERATOR [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 201, "+-*/=<>&|!~%^", false, 0}
Token type: Operators.

const TokenType Ionflux::Tools::TreeEval::TT_PAR_LEFT [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 203, "(", false, 1}
Token type: Parenthesis (left).

const TokenType Ionflux::Tools::TreeEval::TT_PAR_RIGHT [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 204, ")", false, 1}
Token type: Parenthesis (right).

const TokenType Ionflux::Tools::TreeEval::TT_TREEPATH_NP [static]
 

Initial value:

 {
    TokenType::USERTYPE_ID + 202, ".[]", false, 0}
Token type: Tree path (excluding parentheses).


The documentation for this class was generated from the following files:
Generated on Tue Mar 14 21:11:41 2006 for Ionflux Tools Class Library (iftools) by  doxygen 1.4.6