Calling strings as functions in C++ -
i'm writing 'skeleton' front-end in native c++ other users users creating functions 'call' depending on arguments passed in. example:
skeleton.exe /foo param1
would used call function "int dofoo(param1){return 0;}"
inside skeleton. more team members write functions, need add functions well.
a stray thought had - , i'm not if possible - have resource file - or, maybe, resource xml file - list command line arguments, number of parameters , function need call parameter. resource file above like:
foo 1 dofoo
this way, people create functions, have add resource file.
the problem running - , i'm wondering if possible - whether can 'interpret' 'dofoo'
function if read resource file. there allow me 'interpret' string function can call?
you need map strings function pointers.
one method create lookup table use std::map
.
search internet "c++ dispatch" , maybe "c++ double dispatch".
Comments
Post a Comment