17 #define exprtk_disable_string_capabilities   // Workaround a bug in Ubuntu precise's GCC+libstdc++    18 #include <mrpt/otherlibs/exprtk.hpp>    41                 const char* sp = ::getenv(
"MRPT_EXPR_VERBOSE");
    42                 if (
nullptr==sp) 
return;
    61         const std::map<std::string, double> &variables,   
    67         exprtk::symbol_table<double> symbol_table;
    68         for (
const auto &
v : variables) {
    69                 double & var = 
const_cast<double&
>(
v.second);
    70                 symbol_table.add_variable(
v.first, var);
    72         symbol_table.add_constant(
"M_PI", 
M_PI);
    73         symbol_table.add_constants();
    75         PIMPL_GET_REF(exprtk::expression<double>, m_compiled_formula).register_symbol_table(symbol_table);
    77         exprtk::parser<double> parser;
    78         if (!parser.compile(expression, 
PIMPL_GET_REF(exprtk::expression<double>, m_compiled_formula)))
    79                 THROW_EXCEPTION_FMT(
"Error compiling expression (name=`%s`): `%s`. Error: `%s`", expr_name_for_error_reporting.c_str(), expression.c_str(), parser.error().c_str());
    84         ASSERT_(m_compiled_formula.ptr.get() != 
nullptr);
    85         double ret = 
PIMPL_GET_CONSTREF(exprtk::expression<double>, m_compiled_formula).value();
   105                 if (!matched) 
return;
   108         std::vector<std::pair<std::string,double> > lst;
   109         PIMPL_GET_REF(exprtk::expression<double>, rce.m_compiled_formula).get_symbol_table().get_variable_list(lst);
   110         std::cout << 
"[CRuntimeCompiledExpression::eval()] DEBUG:\n"   112                      "* Final value: " << ret << 
"\n"   113                      "* Using these symbols:\n";
   114         for (
const auto &
v : lst)
   115                 std::cout << 
" * " <<  
v.first << 
" = " << 
v.second << 
"\n";
   118 void CRuntimeCompiledExpression::register_symbol_table(
   119         const std::map<std::string, double *> &variables  
   122         exprtk::symbol_table<double> symbol_table;
   123         for (
const auto &
v : variables) {
   124                 double * var = 
const_cast<double*
>(
v.second);
   125                 symbol_table.add_variable(
v.first, *var);
   127         PIMPL_GET_REF(exprtk::expression<double>, m_compiled_formula).register_symbol_table(symbol_table);
   130 exprtk::expression<double> & CRuntimeCompiledExpression::get_raw_exprtk_expr() {
   131         ASSERT_(m_compiled_formula.ptr.get() != 
nullptr);
   132         return PIMPL_GET_REF(exprtk::expression<double>, m_compiled_formula);
   134 const exprtk::expression<double> & CRuntimeCompiledExpression::get_raw_exprtk_expr()
 const {
   135         ASSERT_(m_compiled_formula.ptr.get() != 
nullptr);
   139 bool CRuntimeCompiledExpression::is_compiled()
 const   141         return m_compiled_formula.ptr.get() != 
nullptr;
   143 const std::string & CRuntimeCompiledExpression::get_original_expression()
 const   145         return m_original_expr_str;
 CRuntimeCompiledExpression()
Default ctor. 
 
PIMPL_IMPLEMENT(exprtk::expression< double >)
 
std::vector< std::string > m_verbose_matches
 
#define THROW_EXCEPTION_FMT(_FORMAT_STRING,...)
 
A wrapper of exprtk runtime expression compiler: it takes a string representing an expression (from a...
 
GLsizei GLsizei GLuint * obj
 
void compile(const std::string &expression, const std::map< std::string, double > &variables=std::map< std::string, double >(), const std::string &expr_name_for_error_reporting=std::string())
Initializes the object by compiling an expression. 
 
void process(const CRuntimeCompiledExpression &rce, const double ret)
 
This base provides a set of functions for maths stuff. 
 
double eval() const
Evaluates the current value of the precompiled formula. 
 
#define PIMPL_GET_CONSTREF(_TYPE, _VAR_NAME)
 
static CRuntimeCompiledExpression::ExprVerbose & Instance()
 
bool m_verbose_always_enabled
 
GLsizei const GLchar ** string
 
#define PIMPL_GET_REF(_TYPE, _VAR_NAME)
 
#define PIMPL_CONSTRUCT(_TYPE, _VAR_NAME)
 
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
 
std::string BASE_IMPEXP trim(const std::string &str)
Removes leading and trailing spaces. 
 
std::string m_original_expr_str
 
void BASE_IMPEXP tokenize(const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) MRPT_NO_THROWS
Tokenizes a string according to a set of delimiting characters.