1 #ifndef _settings__hpp__included__
2 #define _settings__hpp__included__
17 * parameter name: Name of the setting.
18 * throws std::bad_alloc: Not enough memory.
20 setting(const std::string
& name
) throw(std::bad_alloc
);
28 * Set the setting to special blank state. Not all settings can be blanked.
30 * throws std::bad_alloc: Not enough memory.
31 * throws std::runtime_error: Blanking this setting is not allowed (currently).
33 virtual void blank() throw(std::bad_alloc
, std::runtime_error
) = 0;
36 * Look up setting and try to blank it.
38 * parameter name: Name of setting to blank.
39 * throws std::bad_alloc: Not enough memory.
40 * throws std::runtime_error: Blanking this setting is not allowed (currently). Or setting does not exist.
42 static void blank(const std::string
& name
) throw(std::bad_alloc
, std::runtime_error
);
45 * Is this setting set (not blanked)?
47 * returns: True if setting is not blanked, false if it is blanked.
49 virtual bool is_set() throw() = 0;
52 * Look up a setting and see if it is set (not blanked)?
54 * parameter name: Name of setting to check.
55 * returns: True if setting is not blanked, false if it is blanked.
56 * throws std::bad_alloc: Not enough memory.
57 * throws std::runtime_error: Setting does not exist.
59 static bool is_set(const std::string
& name
) throw(std::bad_alloc
, std::runtime_error
);
62 * Set value of setting.
64 * parameter value: New value for setting.
65 * throws std::bad_alloc: Not enough memory.
66 * throws std::runtime_error: Setting the setting to this value is not allowed (currently).
68 virtual void set(const std::string
& value
) throw(std::bad_alloc
, std::runtime_error
) = 0;
71 * Look up setting and set it.
73 * parameter name: Name of the setting.
74 * parameter value: New value for setting.
75 * throws std::bad_alloc: Not enough memory.
76 * throws std::runtime_error: Setting the setting to this value is not allowed (currently). Or setting does not exist.
78 static void set(const std::string
& name
, const std::string
& value
) throw(std::bad_alloc
, std::runtime_error
);
81 * Get the value of setting.
83 * returns: The setting value.
84 * throws std::bad_alloc: Not enough memory.
86 virtual std::string
get() throw(std::bad_alloc
) = 0;
89 * Look up setting an get value of it.
91 * returns: The setting value.
92 * throws std::bad_alloc: Not enough memory.
93 * throws std::runtime_error: Setting does not exist.
95 static std::string
get(const std::string
& name
) throw(std::bad_alloc
, std::runtime_error
);
98 * Print all settings and values.
100 * parameter win: The graphics system handle.
101 * throws std::bad_alloc: Not enough memory.
103 static void print_all(window
* win
) throw(std::bad_alloc
);
105 std::string settingname
;
109 * Setting having numeric value.
111 class numeric_setting
: public setting
115 * Create a new numeric setting.
117 * parameter sname: Name of the setting.
118 * parameter minv: Minimum value for the setting.
119 * parameter maxv: Maximum value for the setting.
120 * parameter dflt: Default (initial) value for the setting.
121 * throws std::bad_alloc: Not enough memory.
123 numeric_setting(const std::string
& sname
, int32_t minv
, int32_t maxv
, int32_t dflt
) throw(std::bad_alloc
);
125 * Raises std::runtime_error as these settings can't be blanked.
127 void blank() throw(std::bad_alloc
, std::runtime_error
);
129 * Returns true (these settings are always set).
131 bool is_set() throw();
133 * Set the value of setting. Accepts only numeric values.
135 * parameter value: New value.
136 * throws std::bad_alloc: Not enough memory.
137 * throws std::runtime_error: Invalid value.
139 void set(const std::string
& value
) throw(std::bad_alloc
, std::runtime_error
);
141 * Gets the value of the setting.
143 * returns: Value of setting as string.
144 * throws std::bad_alloc: Not enough memory.
146 std::string
get() throw(std::bad_alloc
);
148 * Get the value of setting as numeric.
150 * returns: Value of the setting as numeric.
152 operator int32_t() throw();
160 * Setting having boolean value.
162 class boolean_setting
: public setting
166 * Create a new boolean setting.
168 * parameter sname: Name of the setting.
169 * parameter dflt: Default (initial) value for the setting.
170 * throws std::bad_alloc: Not enough memory.
172 boolean_setting(const std::string
& sname
, bool dflt
) throw(std::bad_alloc
);
174 * Raises std::runtime_error as these settings can't be blanked.
176 void blank() throw(std::bad_alloc
, std::runtime_error
);
178 * Returns true (these settings are always set).
180 bool is_set() throw();
182 * Set the value of setting.
184 * The following values are accepted as true: true, yes, on, 1, enable and enabled.
185 * The following values are accepted as false: false, no, off, 0, disable and disabled.
187 * parameter value: New value.
188 * throws std::bad_alloc: Not enough memory.
189 * throws std::runtime_error: Invalid value.
191 void set(const std::string
& value
) throw(std::bad_alloc
, std::runtime_error
);
193 * Gets the value of the setting.
195 * returns: Value of setting as string.
196 * throws std::bad_alloc: Not enough memory.
198 std::string
get() throw(std::bad_alloc
);
200 * Get the value of setting as boolean.
202 * returns: Value of the setting as boolean.
204 operator bool() throw();