diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-01-05 22:29:21 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-01-05 22:29:21 +0000 |
commit | b15fcd7592e33b5a837047d0810e5b523fa4a7ad (patch) | |
tree | 79500c31f7ea81128accb3332e356ba16fccbb4a /src/configuration.h | |
parent | b1acd70f999fcd981512829cf6100ad9d358d0e6 (diff) | |
download | mana-b15fcd7592e33b5a837047d0810e5b523fa4a7ad.tar.gz mana-b15fcd7592e33b5a837047d0810e5b523fa4a7ad.tar.bz2 mana-b15fcd7592e33b5a837047d0810e5b523fa4a7ad.tar.xz mana-b15fcd7592e33b5a837047d0810e5b523fa4a7ad.zip |
Small fix in handling spaces around delimiter in ini file.
Diffstat (limited to 'src/configuration.h')
-rw-r--r-- | src/configuration.h | 69 |
1 files changed, 56 insertions, 13 deletions
diff --git a/src/configuration.h b/src/configuration.h index e4239ef0..bae60af3 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -31,31 +31,74 @@ #include <fstream> /** - * INI configuration handler for reading (and writing) + * INI configuration handler for reading (and writing). * * \ingroup CORE */ class Configuration { public: - void init(std::string); + /** + * \brief Reads INI file and parse all options into memory. + * \param filename Full path to INI file (~/.manaworld/tmw.ini) + */ + void init(std::string filename); - bool write(std::string); + /** + * \brief Writes the current settings back to an ini-file. + * \param filename Full path to INI file (~/.manaworld/tmw.ini) + */ + bool write(std::string filename); - void setValue(std::string, std::string); - void setValue(std::string, float); + /** + * \brief Sets an option using a string value. + * \param key Option identifier. + * \param value Value. + */ + void setValue(std::string key, std::string value); - std::string getValue(std::string, std::string); - float getValue(std::string, float); + /** + * \brief Sets an option using a numeric value. + * \param key Option identifier. + * \param value Value. + */ + void setValue(std::string key, float value); + + /** + * \brief Gets a value as string. + * \param key Option identifier. + * \param deflt Default option if not there or error. + */ + std::string getValue(std::string key, std::string deflt); + + /** + * \brief Gets a value as numeric (float). + * \param key Option identifier. + * \param deflt Default option if not there or error. + */ + float getValue(std::string key, float delflt); private: - bool keyExists(std::string); + /** + * Returns wether they given key exists. + */ + bool keyExists(std::string key); + + /** + * A simple data structure to store the value of a configuration + * option. + */ + class OptionValue { + public: + /** + * Constructor. + */ + OptionValue(); - typedef struct INI_OPTION { - std::string stringValue; - float numericValue; + std::string stringValue; + float numericValue; }; - std::map<std::string, INI_OPTION> iniOptions; - std::map<std::string, INI_OPTION>::iterator iter; + std::map<std::string, OptionValue> iniOptions; + std::map<std::string, OptionValue>::iterator iter; }; #endif |