# CppExpressionGenerator Class Reference
[Generating C++ code]

`#include <cppexprgenerator.h>`

List of all members.

## Detailed Description

Helper class for NEDCppGenerator.

Should be used in the following manner:

1. before entering a module declaration, collectExpressions() and generateExpressionClasses() should be called

2. inside the module, where expressions are actually used, generateExpressionUsage() should be called after outputting text like "value="

The internal needsExpressionClass() method decides which expressions are compiled inline and which with expression classes.

## Public Member Functions

| CppExpressionGenerator (ostream &out, NEDSymbolTable *symboltable)
| ~CppExpressionGenerator ()
void | collectExpressions (NEDElement *node)
void | generateExpressionClasses ()
void | generateExpressionUsage (ExpressionNode *expr, const char *indent)

## Protected Types

typedef std::vector< NEDElement * > | NEDElementVector
typedef std::map< ExpressionNode *, ExpressionInfo > | NEDExpressionMap
enum | { MODE_INLINE_EXPRESSION, MODE_EXPRESSION_CLASS }

## Protected Member Functions

void | doExtractArgs (ExpressionInfo &info, NEDElement *node)
void | doCollectExpressions (NEDElement *node, NEDElement *currentSubmodTypeDecl)
void | collectExpressionInfo (ExpressionNode *expr, NEDElement *currentSubmodTypeDecl)
void | generateExpressionClass (ExpressionInfo &info)
const char * | getTypeForArg (NEDElement *node)
const char * | getNameForArg (NEDElement *node)
void | doValueForArg (NEDElement *node)
void | doValueForCachedVar (NEDElement *node)
void | generateChildren (NEDElement *node, const char *indent, int mode)
void | generateItem (NEDElement *node, const char *indent, int mode)
void | doOperator (OperatorNode *node, const char *indent, int mode)
void | doFunction (FunctionNode *node, const char *indent, int mode)
void | doParamref (ParamRefNode *node, const char *indent, int mode)
void | doIdent (IdentNode *node, const char *indent, int mode)
void | doConst (ConstNode *node, const char *indent, int mode)
void | doExpression (ExpressionNode *node, const char *indent, int mode)
bool | needsExpressionClass (ExpressionNode *expr, NEDElement *currentSubmodTypeDecl)

## Protected Attributes

ostream & | out
NEDSymbolTable * | symboltable
NEDExpressionMap | exprMap

## Static Protected Attributes

static int | count

## Classes

struct | ExpressionInfo

## Member Typedef Documentation

typedef std::vector<NEDElement *> CppExpressionGenerator::NEDElementVector`[protected]`

typedef std::map<ExpressionNode *,ExpressionInfo> CppExpressionGenerator::NEDExpressionMap`[protected]`

## Member Enumeration Documentation

anonymous enum`[protected]`

Enumerator:

  MODE_INLINE_EXPRESSION |
  MODE_EXPRESSION_CLASS |

## Constructor & Destructor Documentation

CppExpressionGenerator::CppExpressionGenerator | ( | ostream & | out,
|  | NEDSymbolTable * | symboltable
| ) |

| Constructor.

CppExpressionGenerator::~CppExpressionGenerator | ( |  | ) | `[inline]`

| Destructor.

## Member Function Documentation

void CppExpressionGenerator::collectExpressionInfo | ( | ExpressionNode * | expr,
|  | NEDElement * | currentSubmodTypeDecl
| ) | `[protected]`

void CppExpressionGenerator::collectExpressions | ( | NEDElement * | node | ) |

| Recursively finds all <expression> tags within the passed node, and stores references to them.

void CppExpressionGenerator::doCollectExpressions | ( | NEDElement * | node,
|  | NEDElement * | currentSubmodTypeDecl
| ) | `[protected]`

void CppExpressionGenerator::doConst | ( | ConstNode * | node,
|  | const char * | indent,
|  | int | mode
| ) | `[protected]`

void CppExpressionGenerator::doExpression | ( | ExpressionNode * | node,
|  | const char * | indent,
|  | int | mode
| ) | `[protected]`

void CppExpressionGenerator::doExtractArgs | ( | ExpressionInfo & | info,
|  | NEDElement * | node
| ) | `[protected]`

void CppExpressionGenerator::doFunction | ( | FunctionNode * | node,
|  | const char * | indent,
|  | int | mode
| ) | `[protected]`

void CppExpressionGenerator::doIdent | ( | IdentNode * | node,
|  | const char * | indent,
|  | int | mode
| ) | `[protected]`

void CppExpressionGenerator::doOperator | ( | OperatorNode * | node,
|  | const char * | indent,
|  | int | mode
| ) | `[protected]`

void CppExpressionGenerator::doParamref | ( | ParamRefNode * | node,
|  | const char * | indent,
|  | int | mode
| ) | `[protected]`

void CppExpressionGenerator::doValueForArg | ( | NEDElement * | node | ) | `[protected]`

void CppExpressionGenerator::doValueForCachedVar | ( | NEDElement * | node | ) | `[protected]`

void CppExpressionGenerator::generateChildren | ( | NEDElement * | node,
|  | const char * | indent,
|  | int | mode
| ) | `[protected]`

void CppExpressionGenerator::generateExpressionClass | ( | ExpressionInfo & | info | ) | `[protected]`

void CppExpressionGenerator::generateExpressionClasses | ( |  | ) |

| Generate compiled expression classes (those derived from cExpression) from all stored expressions. The evaluate() methods of the generated classes will hold the expressions.

void CppExpressionGenerator::generateExpressionUsage | ( | ExpressionNode * | expr,
|  | const char * | indent
| ) |

| Generate a cPar initialization code that uses the compiled expression classes generated by generateExpressionClasses().

void CppExpressionGenerator::generateItem | ( | NEDElement * | node,
|  | const char * | indent,
|  | int | mode
| ) | `[protected]`

const char* CppExpressionGenerator::getNameForArg | ( | NEDElement * | node | ) | `[protected]`

const char* CppExpressionGenerator::getTypeForArg | ( | NEDElement * | node | ) | `[protected]`

bool CppExpressionGenerator::needsExpressionClass | ( | ExpressionNode * | expr,
|  | NEDElement * | currentSubmodTypeDecl
| ) | `[protected]`

## Member Data Documentation

int CppExpressionGenerator::count`[static, protected]`

NEDExpressionMap CppExpressionGenerator::exprMap`[protected]`

ostream& CppExpressionGenerator::out`[protected]`

NEDSymbolTable* CppExpressionGenerator::symboltable`[protected]`

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

- cppexprgenerator.h