Base Framework
Public Member Functions | Protected Attributes | List of all members
ExpressionProvider Class Reference

Expression provider. More...

#include <base/math/ExpressionParser.h>

Inherits Object.

Public Member Functions

 ExpressionProvider () noexcept
 
void registerConstant (const String &name, unsigned int id)
 
void registerVariable (const String &name, unsigned int id)
 
void registerFunction (const String &name, unsigned int id, unsigned int arguments)
 
bool isIdentifier (const String &name) const noexcept
 
const StringgetConstant (unsigned int id) const noexcept
 
const StringgetVariable (unsigned int id) const noexcept
 
const StringgetFunction (unsigned int id) const noexcept
 
ExpressionEvaluator::Node getNode (const String &name) const
 
 ~ExpressionProvider () noexcept
 

Protected Attributes

HashTable< String, ExpressionEvaluator::Nodeidentifiers
 
HashTable< unsigned int, Stringconstants
 
HashTable< unsigned int, Stringvariables
 
HashTable< unsigned int, Stringfunctions
 

Detailed Description

Expression provider.

The expression provider is responsible for mapping identifiers into constants, variables, and functions.

See also
ExpressionParser
Version
1.0
Examples
testsuite/eval.cpp.

Constructor & Destructor Documentation

◆ ExpressionProvider()

ExpressionProvider::ExpressionProvider ( )
noexcept

Initializes an expression provider.

◆ ~ExpressionProvider()

ExpressionProvider::~ExpressionProvider ( )
noexcept

Destroys the expression provider.

Member Function Documentation

◆ getConstant()

const String& ExpressionProvider::getConstant ( unsigned int  id) const
inlinenoexcept

Returns the name of the constant with the given id.

◆ getFunction()

const String& ExpressionProvider::getFunction ( unsigned int  id) const
inlinenoexcept

Returns the name of the function with the given id.

◆ getNode()

ExpressionEvaluator::Node ExpressionProvider::getNode ( const String name) const

Returns the evaluation node associated with the specified identifier. Raises InvalidKey if the identifier has not been registered.

Parameters
nameThe identifier to be looked up.

◆ getVariable()

const String& ExpressionProvider::getVariable ( unsigned int  id) const
inlinenoexcept

Returns the name of the variable with the given id.

◆ isIdentifier()

bool ExpressionProvider::isIdentifier ( const String name) const
inlinenoexcept

Returns true if the identifier has been registered.

◆ registerConstant()

void ExpressionProvider::registerConstant ( const String name,
unsigned int  id 
)

Registers an identifier as a constant.

Parameters
nameThe identifier to be registered.
idThe desired id of the constant.
Examples
testsuite/eval.cpp.

◆ registerFunction()

void ExpressionProvider::registerFunction ( const String name,
unsigned int  id,
unsigned int  arguments 
)

Registers an identifier as a function.

Parameters
nameThe identifier to be registered.
idThe desired id of the function.
argumentsThe number of arguments taken by the function.
Examples
testsuite/eval.cpp.

◆ registerVariable()

void ExpressionProvider::registerVariable ( const String name,
unsigned int  id 
)

Registers an identifier as a variable.

Parameters
nameThe identifier to be registered.
idThe desired id of the variable.

Member Data Documentation

◆ constants

HashTable<unsigned int, String> ExpressionProvider::constants
protected

Constants.

◆ functions

HashTable<unsigned int, String> ExpressionProvider::functions
protected

Functions.

◆ identifiers

HashTable<String, ExpressionEvaluator::Node> ExpressionProvider::identifiers
protected

Collection holding the registered identifiers.

◆ variables

HashTable<unsigned int, String> ExpressionProvider::variables
protected

Variables.