list_expr_var.cpp

This example shows how to list variables used in an expression.

void ListExprVar(const mu::ParserBase &parser)
{
  varmap_type variables = parser.GetUsedVar();
  if (!variables.size())
    mu::console() << "Expression does not contain variables\n";
  else
  {
    mu::console() << "Number: " << (int)variables.size() << "\n";
    mu::varmap_type::const_iterator item = variables.begin();

    for (; item!=variables.end(); ++item)
      mu::console() << "Name: " << item->first << "   Address: [0x" << item->second << "]\n";
  }
}


Generated on Sun Jun 22 00:57:25 2008 for muParser by  doxygen 1.5.5