I have several functions in my program that look like this:
void foo(int x, int y)
Now I want my program to take a string that looks like:
foo(3, 5)
And execute the corresponding function. What's the most straightforward way to implement this?
When I say straightforward, I mean reasonably extensible and elegant, but it shouldn't take too long to code up.
Edit:
While using a real scripting language would of course solve my problem, I'd still like to know if there is a quick way to implement this in pure C++.
Scriptable is an automation app that allows you to write short programs (also known as scripts) so your iPhone or iPad can perform almost any task you might imagine—from emailing all meeting attendees to checking the current pollen count with a single command.
You can find it in the Utilities folder inside the Applications folder. You can also use Spotlight to search for “Script Editor” and open it that way. You can learn more about using the Script Editor here.
You can embed Python fairly simply, and that would give you a really powerful, extensible way to script your program. You can use the following to easily (more or less) expose your C++ code to Python:
I personally use Boost Python and I'm happy with it, but it is slow to compile and can be difficult to debug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With