I’ve been thinking of The Right Way (R) to store my program’s internal configuration.
Here’s the details:
- The configuration is runtime only, so generated each run.
- It can be adapted (and should) through directives in a “project” file (the reading of that file is not in the scope of this question)
- It needs to be extensible, ie there should be a way to add new “variables” with assignes values.
My questions about this:
- How should I begin with this? Is a
class with accessors and setters
with an internalstd::mapfor
custom variables a good option? - Are there any known and “good” ways
of doing this? - Should there be a difference between
integer, boolean and string
configuration variables? - Should there be a difference at all
between user and built-in
(pre-existing as in I already
thought of them) variables?
Thanks!
PS: If the question isn’t clear, feel free to ask for more info.
UPDATE: Wow, every answer seems to have implicitely or explicitly used boost. I should have mentioned I’d like to avoid boost (I want to explore the Standard libraries’ capabilities as is for now).
You could do worse than some kind of a property map (
StringMapis just a typedef’d std::map)