by chrisaycock · 5y ago · 0 comments
class Arithmetic : public CommandInterface {
int add(int x, int y) {
return x + y;
}
void register_commands() override {
register_command(&Arithmetic::add, "add", "Add two numbers");
}
};
Simply evaluate a string to invoke the function. Arithmetic arithmetic;
arithmetic.eval("add 3 4"); // returns "7"
The user can place the eval() call behind any interface that has a string for its input and output. I personally use it behind a TCP socket on my trading application; I can query my strategy's state and change its parameters on the fly.If funky C++ interests you, the prop firm I work for is looking to hire engineers. Feel free to contact me directly: chris -AT- chrisaycock -DOT- com
If I understand the design correctly, one can provide a custom argument parser by specializing lexical_cast?