Parse string sqrt(3) to number

Hello!

I would like to read a string like "sqrt(3)" or "pi" from a configfile and parse it to the corresponding double value (1.732.. and 3.14..).

Is there a routine in c++ which can do this for me (kind of an extended lexical_cast or so) or do i have to write a parser for these problems.

Tanks for your information!


lp
Last edited on
There isn't such a function in C++ standards so you may parse the string by yourself
Thank you for your reply. Thats a pity. This functionality would have been very convenient.

lp
A common way to solve this problem is to embed a Python or Lua interpreter in your C++ program, and pass strings to these interpreters for evaluation.

Here's an article on embedding Python: http://www.codeproject.com/KB/cpp/embedpython_1.aspx
Lua seems a little easier to use: http://csl.sublevel3.org/lua/
Thank you for the hint!
Topic archived. No new replies allowed.