1 #ifndef _settings__hpp__included__
2 #define _settings__hpp__included__
15 * \brief Create new setting.
17 * \param name Name of the setting.
18 * \throws std::bad_alloc Not enough memory.
20 setting(const std::string
& name
) throw(std::bad_alloc
);
23 * \brief Remove the setting.
28 * \brief Blank a setting.
30 * Set the setting to special blank state.
32 * \throws std::bad_alloc Not enough memory.
33 * \throws std::runtime_error Blanking this setting is not allowed (currently).
35 virtual void blank() throw(std::bad_alloc
, std::runtime_error
) = 0;
38 * \brief Is this setting set (not blanked)?
40 * \return True if setting is not blanked, false if it is blanked.
42 virtual bool is_set() throw() = 0;
45 * \brief Set value of setting.
47 * \param value New value for setting.
48 * \throws std::bad_alloc Not enough memory.
49 * \throws std::runtime_error Setting the setting to this value is not allowed (currently).
51 virtual void set(const std::string
& value
) throw(std::bad_alloc
, std::runtime_error
) = 0;
54 * \brief Get the value of setting.
56 * \return The setting value.
57 * \throws std::bad_alloc Not enough memory.
59 virtual std::string
get() throw(std::bad_alloc
) = 0;
61 std::string settingname
;
65 * \brief Look up setting and call set() on it.
67 * \param _setting The setting to set.
68 * \param value The value to set it into.
69 * \throws std::bad_alloc Not enough memory.
70 * \throws std::runtime_error Setting the setting to this value is not allowed (currently), or no such setting.
72 void setting_set(const std::string
& _setting
, const std::string
& value
) throw(std::bad_alloc
, std::runtime_error
);
75 * \brief Look up setting and call blank() on it.
77 * \param _setting The setting to blank.
78 * \throws std::bad_alloc Not enough memory.
79 * \throws std::runtime_error Blanking this setting is not allowed (currently), or no such setting.
81 void setting_blank(const std::string
& _setting
) throw(std::bad_alloc
, std::runtime_error
);
84 * \brief Look up setting and call get() on it.
86 * \param _setting The setting to get.
87 * \return The setting value.
88 * \throws std::bad_alloc Not enough memory.
89 * \throws std::runtime_error No such setting.
91 std::string
setting_get(const std::string
& _setting
) throw(std::bad_alloc
, std::runtime_error
);
94 * \brief Look up setting and call is_set() on it.
96 * \param _setting The setting to get.
97 * \return Flase if setting is not blanked, true if it is blanked (note: this is reverse of is_set().
98 * \throws std::bad_alloc Not enough memory.
99 * \throws std::runtime_error No such setting.
101 bool setting_isblank(const std::string
& _setting
) throw(std::bad_alloc
, std::runtime_error
);
104 * \brief Print all settings and values.
106 void setting_print_all(window
* win
) throw(std::bad_alloc
);
108 class numeric_setting
: public setting
111 numeric_setting(const std::string
& sname
, int32_t minv
, int32_t maxv
, int32_t dflt
) throw(std::bad_alloc
);
112 void blank() throw(std::bad_alloc
, std::runtime_error
);
113 bool is_set() throw();
114 void set(const std::string
& value
) throw(std::bad_alloc
, std::runtime_error
);
115 std::string
get() throw(std::bad_alloc
);
116 operator int32_t() throw();
123 class boolean_setting
: public setting
126 boolean_setting(const std::string
& sname
, bool dflt
) throw(std::bad_alloc
);
127 void blank() throw(std::bad_alloc
, std::runtime_error
);
128 bool is_set() throw();
129 void set(const std::string
& value
) throw(std::bad_alloc
, std::runtime_error
);
130 std::string
get() throw(std::bad_alloc
);
131 operator bool() throw();