QuickIO  0.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
config.h
Go to the documentation of this file.
1 
21 #include "qev.h"
22 
26 #define QEV_CFG_GROUP "quick-event"
27 
31 #define QEV_CFG_INCLUDE "include"
32 
36 #define QEV_CFG_LIST_SEPARATOR ','
37 
41 #define QEV_CFG_WRAP_AT 75
42 
51 
56 
61 
66 
71 
76 };
77 
85  gboolean *bool;
86 
90  gint64 *i64;
91 
95  guint64 *ui64;
96 
100  gdouble *dbl;
101 
105  gchar **str;
106 
110  gchar ***strv;
111 };
112 
116 union qev_cfg_val {
120  gint64 bool;
121 
125  gint64 i64;
126 
130  guint64 ui64;
131 
135  gdouble dbl;
136 
140  gchar *str;
141 
146  gchar **strv;
147 };
148 
164 typedef void (*qev_cfg_validator)(
165  const gchar *name,
166  union qev_cfg_val *val,
167  GError **error);
168 
194 typedef void (*qev_cfg_cb)(
195  const gchar *name,
196  union qev_cfg_valptr curr_val,
197  union qev_cfg_val new_val);
198 
211 typedef void (*qev_cfg_listener_cb)(
212  const gchar *name,
213  const gchar *val);
214 
218 struct qev_cfg {
222  gchar *name;
223 
227  gchar *description;
228 
233 
239  union qev_cfg_valptr val;
240 
245 
250 
255 
259  gboolean read_only;
260 };
261 
268 void qev_cfg_set_default_file(const gchar *file_pattern);
269 
283 void qev_cfg_add(
284  const gchar *group_name,
285  const struct qev_cfg *opts,
286  const guint opts_len);
287 
305 void qev_cfg_listen(const gchar *group_name, const qev_cfg_listener_cb cb);
306 
323 void qev_cfg_set(
324  const gchar *group_name,
325  const gchar *name,
326  union qev_cfg_val val,
327  GError **error);
328 
333  const gchar *name,
334  union qev_cfg_val *val,
335  GError **error);
336 
340 guint64 qev_cfg_get_max_clients();
341 
345 guint64 qev_cfg_get_timeout();
guint64 qev_cfg_get_max_clients()
Gets that maximum number of clients that may be connected.
gdouble * dbl
A double.
Definition: config.h:100
A double.
Definition: config.h:65
A string.
Definition: config.h:70
void qev_cfg_set(const gchar *group_name, const gchar *name, union qev_cfg_val val, GError **error)
Dynamically change an option at run time, executing all callbacks, validators, and etc...
gchar *** strv
A value that can be freed with g_strfreev()
Definition: config.h:110
gchar * name
Name of the option.
Definition: config.h:222
gboolean * bool
A boolean.
Definition: config.h:85
void(* qev_cfg_listener_cb)(const gchar *name, const gchar *val)
Callback for listeners.
Definition: config.h:211
union qev_cfg_val defval
The default value for this option.
Definition: config.h:244
qev_cfg_validator validate
Callback for validating / parsing an option when it's set.
Definition: config.h:249
gint64 * i64
Signed, 64bit integer.
Definition: config.h:90
gint64 i64
Signed, 64bit integer.
Definition: config.h:125
gdouble dbl
A double.
Definition: config.h:135
gchar * str
A value that can be freed with g_free()
Definition: config.h:140
Signed, 64bit integer.
Definition: config.h:55
gchar * description
Short description of the option.
Definition: config.h:227
The default values for the values.
Definition: config.h:116
guint64 * ui64
Unsigned, 64bit integer.
Definition: config.h:95
void(* qev_cfg_cb)(const gchar *name, union qev_cfg_valptr curr_val, union qev_cfg_val new_val)
Callback type for after an option has been set / updated, included when it's initialized to its defau...
Definition: config.h:194
qev_cfg_type
Supported option types.
Definition: config.h:46
Unsigned, 64bit integer.
Definition: config.h:60
A boolean.
Definition: config.h:50
Where the values of the options live.
Definition: config.h:81
void qev_cfg_set_default_file(const gchar *file_pattern)
Set the default path to look for the config file(s).
void qev_cfg_listen(const gchar *group_name, const qev_cfg_listener_cb cb)
Receive a callback for every key and value found in group_name.
A string array.
Definition: config.h:75
gchar ** str
A value that can be freed with g_free()
Definition: config.h:105
void qev_cfg_validate_port(const gchar *name, union qev_cfg_val *val, GError **error)
Validating ports is a fairly common task.
guint64 ui64
Unsigned, 64bit integer.
Definition: config.h:130
Provides all the qev_* functions that are needed for creating an event loop.
A configuration option that can be parsed in a config file.
Definition: config.h:218
enum qev_cfg_type type
Type of option.
Definition: config.h:232
guint64 qev_cfg_get_timeout()
Gets the timeout.
void qev_cfg_add(const gchar *group_name, const struct qev_cfg *opts, const guint opts_len)
Add config options under the given group.
gchar ** strv
A value that can be freed with g_strfreev(), length can be found with g_strv_length().
Definition: config.h:146
gint64 bool
A boolean.
Definition: config.h:120
void(* qev_cfg_validator)(const gchar *name, union qev_cfg_val *val, GError **error)
Validation callback for options.
Definition: config.h:164
qev_cfg_cb cb
Callback after the value has been set.
Definition: config.h:254
gboolean read_only
If the config option may be modified at run time.
Definition: config.h:259