EFL 1.7 svn doobies
[profile/ivi/efreet.git] / src / lib / efreet_ini.h
1 #ifndef EFREET_INI_H
2 #define EFREET_INI_H
3
4 /**
5  * @internal
6  * @file efreet_ini.h
7  * @brief A simple and fast INI parser
8  * @addtogroup Efreet_Ini Efreet_Ini: An INI parser
9  *
10  * @{
11  */
12
13 /**
14  * Efreet_Ini
15  */
16 typedef struct Efreet_Ini Efreet_Ini;
17
18 /**
19  * Efreet_Ini
20  * @brief Contains all the information about an ini file.
21  */
22 struct Efreet_Ini
23 {
24   Eina_Hash *data;     /**< Hash of string => (Hash of string => string) */
25   Eina_Hash *section;  /**< currently selected section */
26 };
27
28
29 /**
30  * @param file The file to parse
31  * @return Returns a new Efreet_Ini structure initialized with the contents
32  * of @a file, or NULL on memory allocation failure
33  * @brief Creates and initializes a new Ini structure with the contents of
34  * @a file, or NULL on failure
35  */
36 EAPI Efreet_Ini  *efreet_ini_new(const char *file);
37
38 /**
39  * @param ini The Efreet_Ini to work with
40  * @return Returns no value
41  * @brief Frees the given Efree_Ini structure.
42  */
43 EAPI void         efreet_ini_free(Efreet_Ini *ini);
44
45 /**
46  * @param ini The Efreet_Ini to work with
47  * @param file The file to load
48  * @return Returns no value
49  * @brief Saves the given Efree_Ini structure.
50  */
51 EAPI int          efreet_ini_save(Efreet_Ini *ini, const char *path);
52
53
54 /**
55  * @param ini The Efreet_Ini to work with
56  * @param section The section of the ini file we want to get values from
57  * @return Returns 1 if the section exists, otherwise 0
58  * @brief Sets the current working section of the ini file to @a section
59  */
60 EAPI int          efreet_ini_section_set(Efreet_Ini *ini, const char *section);
61
62 /**
63  * @param ini The Efreet_Ini to work with
64  * @param section The section of the ini file we want to add
65  * @return Returns no value
66  * @brief Adds a new working section of the ini file to @a section
67  */
68 EAPI void         efreet_ini_section_add(Efreet_Ini *ini, const char *section);
69
70
71 /**
72  * @param ini The Efree_Ini to work with
73  * @param key The key to lookup
74  * @return Returns the string associated with the given key or NULL if not
75  * found.
76  * @brief Retrieves the value for the given key or NULL if none found.
77  */
78 EAPI const char  *efreet_ini_string_get(Efreet_Ini *ini, const char *key);
79
80 /**
81  * @param ini The Efree_Ini to work with
82  * @param key The key to use
83  * @param value The value to set
84  * @return Returns no value
85  * @brief Sets the value for the given key
86  */
87 EAPI void         efreet_ini_string_set(Efreet_Ini *ini, const char *key,
88                                                     const char *value);
89
90
91 /**
92  * @param ini The ini struct to work with
93  * @param key The key to search for
94  * @return Returns the utf8 encoded string associated with @a key, or NULL
95  *         if none found
96  * @brief Retrieves the utf8 encoded string associated with @a key in the current locale or NULL if none found
97  */
98 EAPI const char  *efreet_ini_localestring_get(Efreet_Ini *ini, const char *key);
99
100 /**
101  * @param ini The ini struct to work with
102  * @param key The key to use
103  * @param value The value to set
104  * @return Returns no value
105  * @brief Sets the value for the given key
106  */
107 EAPI void         efreet_ini_localestring_set(Efreet_Ini *ini, const char *key,
108                                                     const char *value);
109
110
111 /**
112  * @param ini The ini struct to work with
113  * @param key The key to search for
114  * @return Returns 1 if the boolean is true, 0 otherwise
115  * @brief Retrieves the boolean value at key @a key from the ini @a ini
116  */
117 EAPI unsigned int efreet_ini_boolean_get(Efreet_Ini *ini, const char *key);
118
119 /**
120  * @param ini The ini struct to work with
121  * @param key The key to use
122  * @param value The value to set
123  * @return Returns no value
124  * @brief Sets the value for the given key
125  */
126 EAPI void         efreet_ini_boolean_set(Efreet_Ini *ini, const char *key,
127                                                     unsigned int value);
128
129
130 /**
131  * @param ini The Efree_Ini to work with
132  * @param key The key to lookup
133  * @return Returns the integer associated with the given key or -1 if not
134  * found.
135  * @brief Retrieves the value for the given key or -1 if none found.
136  */
137 EAPI int          efreet_ini_int_get(Efreet_Ini *ini, const char *key);
138
139 /**
140  * @param ini The Efree_Ini to work with
141  * @param key The key to use
142  * @param value The value to set
143  * @return Returns no value
144  * @brief Sets the value for the given key
145  */
146 EAPI void         efreet_ini_int_set(Efreet_Ini *ini, const char *key, int value);
147
148
149 /**
150  * @param ini The Efree_Ini to work with
151  * @param key The key to lookup
152  * @return Returns the double associated with the given key or -1 if not
153  * found.
154  * @brief Retrieves the value for the given key or -1 if none found.
155  */
156 EAPI double       efreet_ini_double_get(Efreet_Ini *ini, const char *key);
157
158 /**
159  * @param ini The Efree_Ini to work with
160  * @param key The key to use
161  * @param value The value to set
162  * @return Returns no value
163  * @brief Sets the value for the given key
164  */
165 EAPI void         efreet_ini_double_set(Efreet_Ini *ini, const char *key,
166                                                     double value);
167
168
169 /**
170  * @param ini The ini struct to work with
171  * @param key The key to remove
172  * @return Returns no value
173  * @brief Remove the given key from the ini struct
174  */
175 EAPI void         efreet_ini_key_unset(Efreet_Ini *ini, const char *key);
176
177 /**
178  * @}
179  */
180
181 #endif