--- I'm rewriting the "settings" portion of an application. I had implemented it hackishly before, and now maintaining it is becoming embarrassing. The trick is that I have three different types of variables (albeit mostly integral) that I'd like the user to be able to set from the command line. However, I'd like to do this in a way that I could arbitrarily increase the number of types in consideration.
--- Mostly the user sets flags, and so that's a set<string, bool>, which works nicely. But other times I want to encounter input like "set_sub-period_4", and know to set the variable labeled sub-period to the value 4.
--- My best idea so far is to have a class setting that contains a string, a void pointer, and a typeid. Then I'll have some function with a bunch of if/else statements testing 'type == typeid(int)...... type == typeid(double)....'
--- Is there a brief way to do this while avoiding blocks of 'if' checks? Fortunately, I am limited to a small set of types.
Any input is appreciated. Also, boost::any doesn't seem to help in this case.