Evaluation context which stores variables and built-in functions.
More...
#include <eval.hpp>
|
| EvalContext (std::unordered_map< std::string, double > vars, std::unordered_map< std::string, builtins::Function > funcs, std::size_t call_depth=0) |
| Construct a new Eval Context object.
|
|
TCALC_INLINE auto & | vars () noexcept |
| Get variables.
|
|
TCALC_INLINE auto & | funcs () noexcept |
| Get built-in functions.
|
|
error::Result< double > | var (const std::string &name) const |
| Get a variable.
|
|
TCALC_INLINE void | var (const std::string &name, double value) noexcept |
| Set a variable.
|
|
error::Result< builtins::Function > | func (const std::string &name) const |
| Get a built-in function.
|
|
TCALC_INLINE void | func (const std::string &name, builtins::Function func) noexcept |
| Set a built-in function.
|
|
TCALC_INLINE auto | call_depth () const noexcept |
| Get the call depth.
|
|
TCALC_INLINE void | call_depth (std::size_t depth) |
| Set the call depth.
|
|
TCALC_INLINE void | increment_call_depth () noexcept |
| Increment the call depth.
|
|
void | update_with (const EvalContext &ctx) |
| Update the context with another context.
|
|
|
static constexpr std::size_t | MAX_CALL_DEPTH = 1000 |
|
Evaluation context which stores variables and built-in functions.
◆ EvalContext()
tcalc::EvalContext::EvalContext |
( |
std::unordered_map< std::string, double > |
vars, |
|
|
std::unordered_map< std::string, builtins::Function > |
funcs, |
|
|
std::size_t |
call_depth = 0 |
|
) |
| |
|
inline |
Construct a new Eval Context object.
- Parameters
-
vars | Variables map. |
funcs | Built-in functions map. |
◆ call_depth() [1/2]
TCALC_INLINE auto tcalc::EvalContext::call_depth |
( |
| ) |
const |
|
inlinenoexcept |
Get the call depth.
- Returns
- std::size_t Call depth.
◆ call_depth() [2/2]
TCALC_INLINE void tcalc::EvalContext::call_depth |
( |
std::size_t |
depth | ) |
|
|
inline |
Set the call depth.
- Parameters
-
◆ func() [1/2]
◆ func() [2/2]
TCALC_INLINE void tcalc::EvalContext::func |
( |
const std::string & |
name, |
|
|
builtins::Function |
func |
|
) |
| |
|
inlinenoexcept |
Set a built-in function.
- Parameters
-
name | Function name. |
func | Function pointer. |
◆ funcs()
TCALC_INLINE auto & tcalc::EvalContext::funcs |
( |
| ) |
|
|
inlinenoexcept |
Get built-in functions.
- Returns
- std::unordered_map<std::string, BuiltinFunc>& Built-in functions map.
◆ update_with()
void tcalc::EvalContext::update_with |
( |
const EvalContext & |
ctx | ) |
|
Update the context with another context.
- Parameters
-
◆ var() [1/2]
error::Result< double > tcalc::EvalContext::var |
( |
const std::string & |
name | ) |
const |
◆ var() [2/2]
TCALC_INLINE void tcalc::EvalContext::var |
( |
const std::string & |
name, |
|
|
double |
value |
|
) |
| |
|
inlinenoexcept |
Set a variable.
- Parameters
-
name | Variable name. |
value | Variable value. |
◆ vars()
TCALC_INLINE auto & tcalc::EvalContext::vars |
( |
| ) |
|
|
inlinenoexcept |
Get variables.
- Returns
- std::unordered_map<std::string, double>& Variables map.
The documentation for this class was generated from the following files: