Open ponzipoh opened 8 years ago
Doesn't sound like it'd make much sense to do at the libconfig level. You should do the detection yourself from the program before adding the setting. It's not difficult ...
Anyway, it's Mark's call.
We could overload add() I guess, to take each type of value, e.g.:
Setting &add(const std::string &name, int value) Setting &add(const std::string &name, double value) Setting &add(const std::string &name, const char *value) ...
When I let a user set a new property to add to a setting, I don't know the type in advance. For example, the user may want to add the config setting balance=42, name="My Name", or loadPlugin=True. The problem is, when I go to store this property in a config file I need to supply a type according to the function definition Setting & add(const std::string &name, Setting::Type type).
Would it please be possible to add a function that selects the type automatically based on the new value that I want to store?