Template Class Calculator¶
Defined in File calc.hh
Class Documentation¶
-
template<typename
T_type
= double>
classcalc_defs
::
Calculator
¶
-
This class implement the expression evaluator
Public Types
-
typedef value_type *
pointer
¶
-
typedef const value_type *
const_pointer
¶
-
typedef value_type &
reference
¶
-
typedef const value_type &
const_reference
¶
-
typedef Calculator<value_type>
CALCULATOR
¶
-
typedef value_type (*
Func1
)(value_type)¶
-
typedef value_type (*
Func2
)(value_type, value_type)¶
-
typedef map<string, value_type>
map_real
¶
Public Functions
-
inline
Calculator
(void)¶
-
inline
~Calculator
(void)¶
-
inline void
init
(void)¶
-
bool
parse
(char const *str)¶
-
This method do a parsing of an input string
- Parameters
-
str – the input string to be parsed
- Returns
-
true if no error parsing errors are found
-
inline bool
parse
(string const &str)¶
-
void
parse_file
(char const *name, bool show_err = false, ostream &stream = cerr)¶
-
This method do a parsing of a whole file
- Parameters
-
name – the name of the input file
show_err – true if you wand message on error parsing
stream – stream for the error messages
-
inline void
parse_file
(string const &name, bool show_err = false, ostream &stream = cerr)¶
-
void
report_error
(ostream &s)¶
-
Print the last error found, noe if no error are found
- Parameters
-
s – the object stream of output
-
inline const_reference
get_value
() const¶
-
\eturn the value of the last evaluated expression
-
void
set
(string const &name, value_type val)¶
-
Set or define a variable
- Parameters
-
name – the name of the variable
val – the value to be stored
-
inline void
set
(char const *name, value_type val)¶
-
inline bool
drop
(string const &name)¶
-
Look if a variable exists and remove from the list
- Parameters
-
name – the name of the variable
- Returns
-
true if the variable exists and is dropped
-
inline bool
drop
(char const *name)¶
-
inline bool
exist
(string const &name) const¶
-
Look if a variable exists
- Parameters
-
name – the name of the variable
- Returns
-
true if the variable exists
-
inline bool
exist
(char const name[]) const¶
-
value_type
get
(string const &name, bool &ok)¶
-
- Parameters
-
name – the name of the variable
ok – true if the variable exists
- Returns
-
the value of the variable
-
inline value_type
get
(char const *name, bool &ok)¶
-
void
print
(ostream &s) const¶
-
Print internal status of the parser: the list of the variables constants and functions
- Parameters
-
s – the object stream of output
-
inline void
set_unary_fun
(char const *f_name, Func1 f_ptr)¶
-
Add unary function to the parser
- Parameters
-
f_name – function name
f_ptr – pointer to the function routine
-
inline void
set_binary_fun
(char const *f_name, Func2 f_ptr)¶
-
Add binary function to the parser
- Parameters
-
f_name – function name
f_ptr – pointer to the function routine
-
inline bool
no_error
() const¶
-
- Returns
-
true if no error found
-
typedef value_type *