OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
settings.hpp
Go to the documentation of this file.
1 #ifndef COMPONENTS_SETTINGS_H
2 #define COMPONENTS_SETTINGS_H
3 
4 #include <set>
5 #include <map>
6 #include <string>
7 
8 namespace Settings
9 {
10  typedef std::pair < std::string, std::string > CategorySetting;
11  typedef std::set< std::pair<std::string, std::string> > CategorySettingVector;
12  typedef std::map < CategorySetting, std::string > CategorySettingValueMap;
13 
17  class Manager
18  {
19  public:
22 
25 
26  void clear();
28 
29  void loadDefault (const std::string& file);
31 
32  void loadUser (const std::string& file);
34 
35  void saveUser (const std::string& file);
37 
38  static const CategorySettingVector apply();
40 
41  static int getInt (const std::string& setting, const std::string& category);
42  static float getFloat (const std::string& setting, const std::string& category);
43  static std::string getString (const std::string& setting, const std::string& category);
44  static bool getBool (const std::string& setting, const std::string& category);
45 
46  static void setInt (const std::string& setting, const std::string& category, const int value);
47  static void setFloat (const std::string& setting, const std::string& category, const float value);
48  static void setString (const std::string& setting, const std::string& category, const std::string& value);
49  static void setBool (const std::string& setting, const std::string& category, const bool value);
50  };
51 
52 }
53 
54 #endif // _COMPONENTS_SETTINGS_H
void loadDefault(const std::string &file)
load file as the default settings (can be overridden by user settings)
Definition: settings.cpp:363
static void setBool(const std::string &setting, const std::string &category, const bool value)
Definition: settings.cpp:437
static void setFloat(const std::string &setting, const std::string &category, const float value)
Definition: settings.cpp:432
static std::string getString(const std::string &setting, const std::string &category)
Definition: settings.cpp:381
void clear()
clears all settings and default settings
Definition: settings.cpp:356
static bool getBool(const std::string &setting, const std::string &category)
Definition: settings.cpp:406
void saveUser(const std::string &file)
save user settings to file
Definition: settings.cpp:375
static void setInt(const std::string &setting, const std::string &category, const int value)
Definition: settings.cpp:427
std::set< std::pair< std::string, std::string > > CategorySettingVector
Definition: settings.hpp:11
std::map< CategorySetting, std::string > CategorySettingValueMap
Definition: settings.hpp:12
static CategorySettingVector mChangedSettings
tracks all the settings that were changed since the last apply() call
Definition: settings.hpp:23
void loadUser(const std::string &file)
load file as user settings
Definition: settings.cpp:369
std::pair< std::string, std::string > CategorySetting
Definition: settings.hpp:10
static CategorySettingValueMap mUserSettings
Definition: settings.hpp:21
static float getFloat(const std::string &setting, const std::string &category)
Definition: settings.cpp:396
static const CategorySettingVector apply()
returns the list of changed settings and then clears it
Definition: settings.cpp:442
Settings management (can change during runtime)
Definition: settings.hpp:17
static CategorySettingValueMap mDefaultSettings
Definition: settings.hpp:20
static void setString(const std::string &setting, const std::string &category, const std::string &value)
Definition: settings.cpp:411
static int getInt(const std::string &setting, const std::string &category)
Definition: settings.cpp:401