aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/efreet/efreet_ini.h
blob: 2c242b3745ccdcaf12c928a827f765b830664d60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#ifndef EFREET_INI_H
#define EFREET_INI_H

/**
 * @internal
 * @file efreet_ini.h
 * @brief A simple and fast INI parser
 *
 * @defgroup Efreet_Ini Efreet_Ini: An INI parser
 * @ingroup Efreet_Group
 *
 * @{
 */

/**
 * Efreet_Ini
 */
typedef struct Efreet_Ini Efreet_Ini;

/**
 * Efreet_Ini
 * @brief Contains all the information about an ini file.
 */
struct Efreet_Ini
{
  Eina_Hash *data;     /**< Hash of string => (Hash of string => string) */
  Eina_Hash *section;  /**< currently selected section */
};


/**
 * @brief Creates and initializes a new Ini structure with the contents of
 * @a file, or NULL on failure
 *
 * @param[in] file The file to parse
 * @return Returns a new Efreet_Ini structure initialized with the contents
 * of @a file, or NULL on memory allocation failure
 */
EAPI Efreet_Ini  *efreet_ini_new(const char *file);

/**
 * @brief Frees the given Efree_Ini structure.
 *
 * @param[in] ini The Efreet_Ini to work with
 * @return Returns no value
 */
EAPI void         efreet_ini_free(Efreet_Ini *ini);

/**
 * @brief Saves the given Efree_Ini structure.
 *
 * @param[in] ini The Efreet_Ini to work with
 * @param[in] path The file path to load
 * @return Returns no value
 */
EAPI int          efreet_ini_save(Efreet_Ini *ini, const char *path);


/**
 * @brief Sets the current working section of the ini file to @a section
 *
 * @param[in] ini The Efreet_Ini to work with
 * @param[in] section The section of the ini file we want to get values from
 * @return Returns 1 if the section exists, otherwise 0
 */
EAPI int          efreet_ini_section_set(Efreet_Ini *ini, const char *section);

/**
 * @brief Adds a new working section of the ini file to @a section
 *
 * @param[in] ini The Efreet_Ini to work with
 * @param[in] section The section of the ini file we want to add
 * @return Returns no value
 */
EAPI void         efreet_ini_section_add(Efreet_Ini *ini, const char *section);


/**
 * @brief Retrieves the value for the given key or NULL if none found.
 *
 * @param[in] ini The Efree_Ini to work with
 * @param[in] key The key to lookup
 * @return Returns the string associated with the given key or NULL if not
 * found.
 */
EAPI const char  *efreet_ini_string_get(Efreet_Ini *ini, const char *key);

/**
 * @brief Sets the value for the given key
 *
 * @param[in] ini The Efree_Ini to work with
 * @param[in] key The key to use
 * @param[in] value The value to set
 * @return Returns no value
 */
EAPI void         efreet_ini_string_set(Efreet_Ini *ini, const char *key,
                                                    const char *value);


/**
 * @brief Retrieves the utf8 encoded string associated with @a key in the current locale or NULL if none found
 *
 * @param[in] ini The ini struct to work with
 * @param[in] key The key to search for
 * @return Returns the utf8 encoded string associated with @a key, or NULL
 *         if none found
 */
EAPI const char  *efreet_ini_localestring_get(Efreet_Ini *ini, const char *key);

/**
 * @brief Sets the value for the given key
 *
 * @param[in] ini The ini struct to work with
 * @param[in] key The key to use
 * @param[in] value The value to set
 * @return Returns no value
 */
EAPI void         efreet_ini_localestring_set(Efreet_Ini *ini, const char *key,
                                                    const char *value);


/**
 * @brief Retrieves the boolean value at key @a key from the ini @a ini
 *
 * @param[in] ini The ini struct to work with
 * @param[in] key The key to search for
 * @return Returns 1 if the boolean is true, 0 otherwise
 */
EAPI unsigned int efreet_ini_boolean_get(Efreet_Ini *ini, const char *key);

/**
 * @brief Sets the value for the given key
 *
 * @param[in] ini The ini struct to work with
 * @param[in] key The key to use
 * @param[in] value The value to set
 * @return Returns no value
 */
EAPI void         efreet_ini_boolean_set(Efreet_Ini *ini, const char *key,
                                                    unsigned int value);


/**
 * @brief Retrieves the value for the given key or -1 if none found.
 *
 * @param[in] ini The Efree_Ini to work with
 * @param[in] key The key to lookup
 * @return Returns the integer associated with the given key or -1 if not
 * found.
 */
EAPI int          efreet_ini_int_get(Efreet_Ini *ini, const char *key);

/**
 * @brief Sets the value for the given key
 *
 * @param[in] ini The Efree_Ini to work with
 * @param[in] key The key to use
 * @param[in] value The value to set
 * @return Returns no value
 */
EAPI void         efreet_ini_int_set(Efreet_Ini *ini, const char *key, int value);


/**
 * @brief Retrieves the value for the given key or -1 if none found.
 *
 * @param[in] ini The Efree_Ini to work with
 * @param[in] key The key to lookup
 * @return Returns the double associated with the given key or -1 if not
 * found.
 */
EAPI double       efreet_ini_double_get(Efreet_Ini *ini, const char *key);

/**
 * @brief Sets the value for the given key
 *
 * @param[in] ini The Efree_Ini to work with
 * @param[in] key The key to use
 * @param[in] value The value to set
 * @return Returns no value
 */
EAPI void         efreet_ini_double_set(Efreet_Ini *ini, const char *key,
                                                    double value);


/**
 * @brief Remove the given key from the ini struct
 *
 * @param[in] ini The ini struct to work with
 * @param[in] key The key to remove
 * @return Returns no value
 */
EAPI void         efreet_ini_key_unset(Efreet_Ini *ini, const char *key);

/**
 * @}
 */

#endif