GCS  0.2.3
gu_config.h
Go to the documentation of this file.
1 // Copyright (C) 2010-2014 Codership Oy <info@codership.com>
2 
10 #ifndef _gu_config_h_
11 #define _gu_config_h_
12 
13 #include <stdint.h>
14 #include <stdbool.h>
15 #include <unistd.h> // for ssize_t
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 typedef struct gu_config gu_config_t;
22 
23 gu_config_t*
24 gu_config_create ();
25 
26 void
27 gu_config_destroy (gu_config_t* cnf);
28 
29 bool
30 gu_config_has (gu_config_t* cnf, const char* key);
31 
32 bool
33 gu_config_is_set (gu_config_t* cnf, const char* key);
34 
35 /* before setting a parameter, it must be added to a known parameter list*/
36 void
37 gu_config_add (gu_config_t* cnf, const char* key,
38  const char* val /*can be NULL*/);
39 
40 /* Getters/setters return 0 on success, 1 when key not set/not found,
41  * negative error code in case of other errors (conversion failed and such) */
42 
43 int
44 gu_config_get_string (gu_config_t* cnf, const char* key, const char** val);
45 
46 int
47 gu_config_get_int64 (gu_config_t* cnf, const char* key, int64_t* val);
48 
49 int
50 gu_config_get_double (gu_config_t* cnf, const char* key, double* val);
51 
52 int
53 gu_config_get_ptr (gu_config_t* cnf, const char* key, void** val);
54 
55 int
56 gu_config_get_bool (gu_config_t* cnf, const char* key, bool* val);
57 
58 void
59 gu_config_set_string (gu_config_t* cnf, const char* key, const char* val);
60 
61 void
62 gu_config_set_int64 (gu_config_t* cnf, const char* key, int64_t val);
63 
64 void
65 gu_config_set_double (gu_config_t* cnf, const char* key, double val);
66 
67 void
68 gu_config_set_ptr (gu_config_t* cnf, const char* key, const void* val);
69 
70 void
71 gu_config_set_bool (gu_config_t* cnf, const char* key, bool val);
72 
73 ssize_t
74 gu_config_print (gu_config_t* cnf, char* buf, ssize_t buf_len);
75 
76 #ifdef __cplusplus
77 }
78 #endif
79 
80 #endif /* _gu_config_h_ */
81