24#ifndef TOKENIZER_H_INCLUDED
25#define TOKENIZER_H_INCLUDED
67 const std::lock_guard<std::mutex> lock(this->mutex);
68 bool overwritten =
false;
71 p.DefineConst(name, (mu::value_type)value);
79 std::vector<std::string> exprVariables(
const std::string eq);
86 template<
typename T=
float>
89 const std::lock_guard<std::mutex> lock(this->mutex);
96 if (sz == eq.size()) {
102 std::string::size_type sz;
104 if (sz == eq.size()) {
111 mu::value_type res_org;
116 }
catch (mu::Parser::exception_type& e) {
117 std::ostringstream msg;
118 msg <<
"Error evaluating \"" << e.GetExpr() <<
"\"" << std::endl;
119 msg <<
"input = \"" << eq <<
"\"" << std::endl;
122 msg <<
"\t" << e.GetMsg() << std::endl;
125 msg <<
"\tToken " << e.GetToken() <<
" in position " << e.GetPos()
129 }
catch(std::out_of_range&) {
130 LOG(
L_ERROR, std::string(
"Error evaluating \"") + eq +
"\":\n");
133 std::to_string(res_org) +
" overflows the type \"" +
134 typeid(res).name() +
"\"\n");
148 bool isVariable(
const std::string name);
155 template<
typename T=
float>
160 mu::valmap_type cmap = p.GetConst();
171 static std::mutex mutex;
Set of auxiliar functions.
Terminal output, with Log automatic copying. (See Aqua::InputOutput::Logger for details)
#define LOG0(level, log)
Definition Logger.hpp:64
#define LOG(level, log)
Definition Logger.hpp:55
#define T
Definition Sort.hcl.in:83
bool isVariable(const std::string name)
Checks if a variable has been registered.
Definition Tokenizer_muparser.cpp:113
T variable(const std::string name)
Returns a variable value.
Definition Tokenizer_muparser.hpp:156
T solve(const std::string eq)
Solve a math expression.
Definition Tokenizer_muparser.hpp:87
bool registerVariable(const std::string name, T value)
Register a variable.
Definition Tokenizer_muparser.hpp:65
Tokenizer_muparser()
Constructor.
Definition Tokenizer_muparser.cpp:53
Main AQUAgpusph namespace.
Definition ArgumentsManager.cpp:50
Tdst narrow_cast(Torg v)
Cast a value, checking that it is not overflowing.
Definition AuxiliarMethods.hpp:414
@ L_ERROR
Definition Logger.hpp:75
@ L_WARNING
Definition Logger.hpp:74
@ L_DEBUG
Definition Logger.hpp:72
#define DECLDIR
Prefix to export C functions on the compiled library.
Definition sphPrerequisites.hpp:65