ruffy
ruffy

Reputation: 391

Get string of specific function name in C++

In my C++ project I want to refer to a specific set of functions with strings.

Basically I want to announce certain abilities of a class to a string-array.

Like this:

class Dog{
    public:
        doBark(){}
        doPoop(){}
        doLick(){}
        doWalk(){}
        doRun(){}
        otherFunction(){}
        getAbilities(){}
}

And getActions() should return a string array (or vector) with the function names starting with "do".

In case any one wonders why: In a framework I use I can only use a certain set of types such as strings. My objects should tell the framework what they can do, so that tasks can be planned accord to their ability. Later, strings should be mapped back to functions, about which I already found useful answers on here.

Now my question: Is this even possible? If yes, how?

Upvotes: 2

Views: 482

Answers (1)

Code-Apprentice
Code-Apprentice

Reputation: 83567

Remember that function names as well as variable names are only available at compile time. Once a program is compiled into machine code, these names not available without some serious convolutions to load the debug symbols similar to a source-level debugger.

Upvotes: 5

Related Questions