g_key_file_has_key_full: New function to fix g_key_file_has_key()'s GError semantics
[platform/upstream/glib.git] / glib / gkeyfile.h
1 /* gkeyfile.h - desktop entry file parser
2  *
3  *  Copyright 2004 Red Hat, Inc.
4  *
5  *  Ray Strode <halfline@hawaii.rr.com>
6  *
7  * GLib is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as
9  * published by the Free Software Foundation; either version 2 of the
10  * License, or (at your option) any later version.
11  *
12  * GLib is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with GLib; see the file COPYING.LIB.  If not,
19  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20  *   Boston, MA 02111-1307, USA.
21  */
22
23 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
24 #error "Only <glib.h> can be included directly."
25 #endif
26
27 #ifndef __G_KEY_FILE_H__
28 #define __G_KEY_FILE_H__
29
30 #include <glib/gerror.h>
31
32 G_BEGIN_DECLS
33
34 typedef enum
35 {
36   G_KEY_FILE_ERROR_UNKNOWN_ENCODING,
37   G_KEY_FILE_ERROR_PARSE,
38   G_KEY_FILE_ERROR_NOT_FOUND,
39   G_KEY_FILE_ERROR_KEY_NOT_FOUND,
40   G_KEY_FILE_ERROR_GROUP_NOT_FOUND,
41   G_KEY_FILE_ERROR_INVALID_VALUE
42 } GKeyFileError;
43
44 #define G_KEY_FILE_ERROR g_key_file_error_quark()
45
46 GQuark g_key_file_error_quark (void);
47
48 typedef struct _GKeyFile GKeyFile;
49
50 typedef enum
51 {
52   G_KEY_FILE_NONE              = 0,
53   G_KEY_FILE_KEEP_COMMENTS     = 1 << 0,
54   G_KEY_FILE_KEEP_TRANSLATIONS = 1 << 1
55 } GKeyFileFlags;
56
57 GKeyFile *g_key_file_new                    (void);
58 void      g_key_file_free                   (GKeyFile             *key_file);
59 void      g_key_file_set_list_separator     (GKeyFile             *key_file,
60                                              gchar                 separator);
61 gboolean  g_key_file_load_from_file         (GKeyFile             *key_file,
62                                              const gchar          *file,
63                                              GKeyFileFlags         flags,
64                                              GError              **error);
65 gboolean  g_key_file_load_from_data         (GKeyFile             *key_file,
66                                              const gchar          *data,
67                                              gsize                 length,
68                                              GKeyFileFlags         flags,
69                                              GError              **error);
70 gboolean g_key_file_load_from_dirs          (GKeyFile             *key_file,
71                                              const gchar          *file,
72                                              const gchar         **search_dirs,
73                                              gchar               **full_path,
74                                              GKeyFileFlags         flags,
75                                              GError              **error);
76 gboolean g_key_file_load_from_data_dirs     (GKeyFile             *key_file,
77                                              const gchar          *file,
78                                              gchar               **full_path,
79                                              GKeyFileFlags         flags,
80                                              GError              **error);
81 gchar    *g_key_file_to_data                (GKeyFile             *key_file,
82                                              gsize                *length,
83                                              GError              **error) G_GNUC_MALLOC;
84 gchar    *g_key_file_get_start_group        (GKeyFile             *key_file) G_GNUC_MALLOC;
85 gchar   **g_key_file_get_groups             (GKeyFile             *key_file,
86                                              gsize                *length) G_GNUC_MALLOC;
87 gchar   **g_key_file_get_keys               (GKeyFile             *key_file,
88                                              const gchar          *group_name,
89                                              gsize                *length,
90                                              GError              **error) G_GNUC_MALLOC;
91 gboolean  g_key_file_has_group              (GKeyFile             *key_file,
92                                              const gchar          *group_name);
93 gboolean  g_key_file_has_key                (GKeyFile             *key_file,
94                                              const gchar          *group_name,
95                                              const gchar          *key,
96                                              GError              **error);
97 gboolean  g_key_file_has_key_full           (GKeyFile             *key_file,
98                                              const gchar          *group_name,
99                                              const gchar          *key,
100                                              gboolean             *has_key,
101                                              GError              **error);
102 gchar    *g_key_file_get_value              (GKeyFile             *key_file,
103                                              const gchar          *group_name,
104                                              const gchar          *key,
105                                              GError              **error) G_GNUC_MALLOC;
106 void      g_key_file_set_value              (GKeyFile             *key_file,
107                                              const gchar          *group_name,
108                                              const gchar          *key,
109                                              const gchar          *value);
110 gchar    *g_key_file_get_string             (GKeyFile             *key_file,
111                                              const gchar          *group_name,
112                                              const gchar          *key,
113                                              GError              **error) G_GNUC_MALLOC;
114 void      g_key_file_set_string             (GKeyFile             *key_file,
115                                              const gchar          *group_name,
116                                              const gchar          *key,
117                                              const gchar          *string);
118 gchar    *g_key_file_get_locale_string      (GKeyFile             *key_file,
119                                              const gchar          *group_name,
120                                              const gchar          *key,
121                                              const gchar          *locale,
122                                              GError              **error) G_GNUC_MALLOC;
123 void      g_key_file_set_locale_string      (GKeyFile             *key_file,
124                                              const gchar          *group_name,
125                                              const gchar          *key,
126                                              const gchar          *locale,
127                                              const gchar          *string);
128 gboolean  g_key_file_get_boolean            (GKeyFile             *key_file,
129                                              const gchar          *group_name,
130                                              const gchar          *key,
131                                              GError              **error);
132 void      g_key_file_set_boolean            (GKeyFile             *key_file,
133                                              const gchar          *group_name,
134                                              const gchar          *key,
135                                              gboolean              value);
136 gint      g_key_file_get_integer            (GKeyFile             *key_file,
137                                              const gchar          *group_name,
138                                              const gchar          *key,
139                                              GError              **error);
140 void      g_key_file_set_integer            (GKeyFile             *key_file,
141                                              const gchar          *group_name,
142                                              const gchar          *key,
143                                              gint                  value);
144 gint64    g_key_file_get_int64              (GKeyFile             *key_file,
145                                              const gchar          *group_name,
146                                              const gchar          *key,
147                                              GError              **error);
148 void      g_key_file_set_int64              (GKeyFile             *key_file,
149                                              const gchar          *group_name,
150                                              const gchar          *key,
151                                              gint64                value);
152 guint64   g_key_file_get_uint64             (GKeyFile             *key_file,
153                                              const gchar          *group_name,
154                                              const gchar          *key,
155                                              GError              **error);
156 void      g_key_file_set_uint64             (GKeyFile             *key_file,
157                                              const gchar          *group_name,
158                                              const gchar          *key,
159                                              guint64               value);
160 gdouble   g_key_file_get_double             (GKeyFile             *key_file,
161                                              const gchar          *group_name,
162                                              const gchar          *key,
163                                              GError              **error);
164 void      g_key_file_set_double             (GKeyFile             *key_file,
165                                              const gchar          *group_name,
166                                              const gchar          *key,
167                                              gdouble               value);
168 gchar   **g_key_file_get_string_list        (GKeyFile             *key_file,
169                                              const gchar          *group_name,
170                                              const gchar          *key,
171                                              gsize                *length,
172                                              GError              **error) G_GNUC_MALLOC;
173 void      g_key_file_set_string_list        (GKeyFile             *key_file,
174                                              const gchar          *group_name,
175                                              const gchar          *key,
176                                              const gchar * const   list[],
177                                              gsize                 length);
178 gchar   **g_key_file_get_locale_string_list (GKeyFile             *key_file,
179                                              const gchar          *group_name,
180                                              const gchar          *key,
181                                              const gchar          *locale,
182                                              gsize                *length,
183                                              GError              **error) G_GNUC_MALLOC;
184 void      g_key_file_set_locale_string_list (GKeyFile             *key_file,
185                                              const gchar          *group_name,
186                                              const gchar          *key,
187                                              const gchar          *locale,
188                                              const gchar * const   list[],
189                                              gsize                 length);
190 gboolean *g_key_file_get_boolean_list       (GKeyFile             *key_file,
191                                              const gchar          *group_name,
192                                              const gchar          *key,
193                                              gsize                *length,
194                                              GError              **error) G_GNUC_MALLOC;
195 void      g_key_file_set_boolean_list       (GKeyFile             *key_file,
196                                              const gchar          *group_name,
197                                              const gchar          *key,
198                                              gboolean              list[],
199                                              gsize                 length);
200 gint     *g_key_file_get_integer_list       (GKeyFile             *key_file,
201                                              const gchar          *group_name,
202                                              const gchar          *key,
203                                              gsize                *length,
204                                              GError              **error) G_GNUC_MALLOC;
205 void      g_key_file_set_double_list        (GKeyFile             *key_file,
206                                              const gchar          *group_name,
207                                              const gchar          *key,
208                                              gdouble               list[],
209                                              gsize                 length);
210 gdouble  *g_key_file_get_double_list        (GKeyFile             *key_file,
211                                              const gchar          *group_name,
212                                              const gchar          *key,
213                                              gsize                *length,
214                                              GError              **error) G_GNUC_MALLOC;
215 void      g_key_file_set_integer_list       (GKeyFile             *key_file,
216                                              const gchar          *group_name,
217                                              const gchar          *key,
218                                              gint                  list[],
219                                              gsize                 length);
220 gboolean  g_key_file_set_comment            (GKeyFile             *key_file,
221                                              const gchar          *group_name,
222                                              const gchar          *key,
223                                              const gchar          *comment,
224                                              GError              **error);
225 gchar    *g_key_file_get_comment            (GKeyFile             *key_file,
226                                              const gchar          *group_name,
227                                              const gchar          *key,
228                                              GError              **error) G_GNUC_MALLOC;
229
230 gboolean  g_key_file_remove_comment         (GKeyFile             *key_file,
231                                              const gchar          *group_name,
232                                              const gchar          *key,
233                                              GError              **error);
234 gboolean  g_key_file_remove_key             (GKeyFile             *key_file,
235                                              const gchar          *group_name,
236                                              const gchar          *key,
237                                              GError              **error);
238 gboolean  g_key_file_remove_group           (GKeyFile             *key_file,
239                                              const gchar          *group_name,
240                                              GError              **error);
241
242 /* Defines for handling freedesktop.org Desktop files */
243 #define G_KEY_FILE_DESKTOP_GROUP                "Desktop Entry"
244
245 #define G_KEY_FILE_DESKTOP_KEY_TYPE             "Type"
246 #define G_KEY_FILE_DESKTOP_KEY_VERSION          "Version"
247 #define G_KEY_FILE_DESKTOP_KEY_NAME             "Name"
248 #define G_KEY_FILE_DESKTOP_KEY_GENERIC_NAME     "GenericName"
249 #define G_KEY_FILE_DESKTOP_KEY_NO_DISPLAY       "NoDisplay"
250 #define G_KEY_FILE_DESKTOP_KEY_COMMENT          "Comment"
251 #define G_KEY_FILE_DESKTOP_KEY_ICON             "Icon"
252 #define G_KEY_FILE_DESKTOP_KEY_HIDDEN           "Hidden"
253 #define G_KEY_FILE_DESKTOP_KEY_ONLY_SHOW_IN     "OnlyShowIn"
254 #define G_KEY_FILE_DESKTOP_KEY_NOT_SHOW_IN      "NotShowIn"
255 #define G_KEY_FILE_DESKTOP_KEY_TRY_EXEC         "TryExec"
256 #define G_KEY_FILE_DESKTOP_KEY_EXEC             "Exec"
257 #define G_KEY_FILE_DESKTOP_KEY_PATH             "Path"
258 #define G_KEY_FILE_DESKTOP_KEY_TERMINAL         "Terminal"
259 #define G_KEY_FILE_DESKTOP_KEY_MIME_TYPE        "MimeType"
260 #define G_KEY_FILE_DESKTOP_KEY_CATEGORIES       "Categories"
261 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_NOTIFY   "StartupNotify"
262 #define G_KEY_FILE_DESKTOP_KEY_STARTUP_WM_CLASS "StartupWMClass"
263 #define G_KEY_FILE_DESKTOP_KEY_URL              "URL"
264
265 #define G_KEY_FILE_DESKTOP_TYPE_APPLICATION     "Application"
266 #define G_KEY_FILE_DESKTOP_TYPE_LINK            "Link"
267 #define G_KEY_FILE_DESKTOP_TYPE_DIRECTORY       "Directory"
268
269 G_END_DECLS
270
271 #endif /* __G_KEY_FILE_H__ */