VLink  2.0.0
A high-performance communication middleware
vlink::ExprtkExpression Class Referencefinal

Opaque wrapper around exprtk::expression<double> plus its compiler. More...

#include <exprtk_api.h>

Collaboration diagram for vlink::ExprtkExpression:

Public Member Functions

 ExprtkExpression ()
 Construct an empty, uncompiled expression. More...
 
 ~ExprtkExpression ()
 Destroy the expression and release the underlying ExprTk state. More...
 
 ExprtkExpression (ExprtkExpression &&) noexcept
 Move constructor; transfers ownership of the underlying ExprTk state. More...
 
ExprtkExpressionoperator= (ExprtkExpression &&) noexcept
 Move assignment; transfers ownership of the underlying ExprTk state. More...
 
void register_symbol_table (ExprtkSymbolTable &symbol_table)
 Bind a symbol table to this expression. More...
 
bool compile (const std::string &expression)
 Compile an expression string against the registered symbol table. More...
 
double value () const
 Evaluate the compiled expression using the current variable values. More...
 

Detailed Description

Opaque wrapper around exprtk::expression<double> plus its compiler.

Bundles a compiled expression and the one-shot parser used to build it. Register a ExprtkSymbolTable, call compile once, then call value repeatedly; the referenced symbol table must outlive the expression.

The class is move-only; the underlying ExprTk expression lives on the heap behind a std::unique_ptr, so moving the wrapper never relocates it.

Constructor & Destructor Documentation

◆ ExprtkExpression() [1/2]

vlink::ExprtkExpression::ExprtkExpression ( )

Construct an empty, uncompiled expression.

◆ ~ExprtkExpression()

vlink::ExprtkExpression::~ExprtkExpression ( )

Destroy the expression and release the underlying ExprTk state.

◆ ExprtkExpression() [2/2]

vlink::ExprtkExpression::ExprtkExpression ( ExprtkExpression &&  )
noexcept

Move constructor; transfers ownership of the underlying ExprTk state.

Member Function Documentation

◆ compile()

bool vlink::ExprtkExpression::compile ( const std::string &  expression)

Compile an expression string against the registered symbol table.

Parameters
expressionThe ExprTk expression source to compile.
Returns
true on success; false if the string failed to parse, in which case value must not be called.
Note
Intended to be called once per object. A registered symbol table is required.

◆ operator=()

ExprtkExpression& vlink::ExprtkExpression::operator= ( ExprtkExpression &&  )
noexcept

Move assignment; transfers ownership of the underlying ExprTk state.

◆ register_symbol_table()

void vlink::ExprtkExpression::register_symbol_table ( ExprtkSymbolTable symbol_table)

Bind a symbol table to this expression.

Parameters
symbol_tableThe table whose constants and variables the expression resolves against. It must outlive this expression; only its address is referenced. Call before compile.

◆ value()

double vlink::ExprtkExpression::value ( ) const

Evaluate the compiled expression using the current variable values.

Returns
The evaluated result. Undefined if compile has not returned true.

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