Archived

This topic is now archived and is closed to further replies.

MB

exec analogon in C++

Recommended Posts

following problem: I receive a string from a stream object, which is in fact a valid command. Let''s assume the string is: string "execute(4.0f)" and the corresponding function would be: execute(float input) How to cast this into a command? In JavaScript there was the nice "exec" statemaent, but how would I do this in C++?

Share this post


Link to post
Share on other sites
As C++ doesn''t have the required reflexive capabilities, not at all. You can of course implement something like that, but there is no native way to handle it. Chances are though, that describing what you need it for might result in a better solution.

Share this post


Link to post
Share on other sites
I guess if you put all your commands into function objects you could come up with a map between the name and the function. you''d have to group them by number of parameters and types passed but it would work.

look into boost.function

Share this post


Link to post
Share on other sites
thanks for the comments, confirming what I supposed.


btw - I looked for the boost extension, but had difficulties installing the little compiler program that you need.
Any experience with that?


Share this post


Link to post
Share on other sites