SETUPMANAGER

Classes

Files

This class can be used when your application needs to remember something between starts. You can easilly store data here and let it automatically take care of saving and loading it. However, be carefull what you are saving here, because it is stored in a plain-text file. It is OK to remember window layout, default walues, language settings or so, but it is a bad idea to store passwords here, for example.

Item identification

Each item is specified by two std::string s. One is called section and the other is value_name. The point is, that the whole setup is divided into sections and inside them, they can not have identical names. However, you can have more items with the same names, as long as they are each in other section.

Interface

File format

The setup file is very similar to the ini file. Lines starting with # are comments. But note, all comments will be lost if the file is saved. Comments makes sence only for read-only setup (do not automanage and load it after that). File looking like [this] means start of section (with the name between that brackets) and other lines all values. It should look like name=value.

Error handling

It is done like elsewhere in vorlib, trough the exception class's heirs. This one is setupmanager_e. The error ids are here:

Recommended use

You should test, weather the file you want to load exists and, if not, create an empty one. Then, when you load some value, put it between try-catch and test, weather it has been loaded. If not (it is not inside), set the value you are loading to some default (but not the manager) and if it changes (by user or so), put it into the setup. That will lead to setup file that will contain only non-default values (or, lets say, changed) and it will not crash when it does not have the setup file, it will just create new one and start with defaults.