ivutils
Loading...
Searching...
No Matches
AlgebraicParser Class Reference

This class allows to parse and calculate algebraic expression with + - * /, brackets () and some constants and functions. More...

#include <alg_parser.h>

Public Member Functions

int operator() (const std::string &str, double *val)
 calculate the algebraic expression str and record the result in val.
 

Detailed Description

This class allows to parse and calculate algebraic expression with + - * /, brackets () and some constants and functions.

constants and functions should be recorded in corresponding maps (see below). f. e. "sqrt(5+cos(3*pi))" Main function of the class is operator() which calculates given algebraic expression. Maps for constants and functions are filled in constructor with some common contans and functions (as pi or cos). User can add some other funtions to these maps, f. e. functions["sqrt"]=sqrt

Member Function Documentation

◆ operator()()

int AlgebraicParser::operator() ( const std::string &  str,
double *  val 
)

calculate the algebraic expression str and record the result in val.

if str is correct returns 1, otherwise returns -1.
str can have + - * /, brackets () and some constants and functions which are recorded in corresponding maps (see above). f.e., str="sqrt(5+cos(3*pi))". T could be float or double.


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