24std::optional<double>
evaluate(std::string_view expression,
25 const std::map<std::string, double>& variables = {});
33 void set(std::string_view name,
double value);
36 std::optional<double>
get(std::string_view name)
const;
39 std::optional<double>
evaluate(std::string_view expression)
const;
48 std::map<std::string, double, std::less<>> variables_;
49 std::map<std::string, std::function<double(
double)>, std::less<>> custom_functions_;
std::optional< double > evaluate(std::string_view expression) const
Evaluate an expression using the stored variables.
void register_function(std::string_view name, std::function< double(double)> fn)
Register a custom function (1 argument).
std::optional< double > get(std::string_view name) const
Get a variable value.
void clear_variables()
Clear all variables.
void set(std::string_view name, double value)
Set a variable value.
ExpressionEvaluator()=default
Definition generated_event_source.hpp:33
std::optional< double > evaluate(std::string_view expression, const std::map< std::string, double > &variables={})
Evaluate a math expression string.