gtorrent / gtorrent-core

Core library of gTorrent which handles everything but UI/UX
GNU General Public License v3.0
39 stars 12 forks source link

Implement settings. #78

Closed fuyukaidesu closed 10 years ago

fuyukaidesu commented 10 years ago

The settings currently implemented aren't all there is to libtorrent, but probably some major settings. Fixes some bugs, too, and rename >>>offensive variables.

To use, #include "Settings.h", and gt::Settings::settings[key], where key is a string, and the value returned by the expression is a string. If the key doesn't exist, it'll return an empty string. The configuration file is completely rewritten when saving, trashing any comments, keys that were missing in the file will be saved too.

Regarding this behavior, you may notice that most utilities that relies on a config file written by the user doesn't not modify it, ever, while the programs that do not ask the user to manually configure it completely rewrite their configs, and may even encode it in a format that can't be easily modified.

If we don't touch the config except for reading, then we won't be able to edit the config later with changes made at runtime, except of course implementing a parser ourselves or adding another library.

We should leave the capacity to the user of modifying the configuration himself, but without guaranteeing him he'll keep any comment or unneeded things in the config. This will enable the user to customize the configuration file while keeping the ability to make changes at runtime.