1Glib::KeyFile(3)      User Contributed Perl Documentation     Glib::KeyFile(3)
2
3
4

NAME

6       Glib::KeyFile -  Parser for .ini-like files
7

SYNOPSIS

9         use Glib;
10
11         $data .= $_ while (<DATA>);
12
13         $f = Glib::KeyFile->new;
14         $f->load_from_data($data);
15         if ($f->has_group('Main') && $f->has_key('Main', 'someotherkey')) {
16             $val = $f->get_integer('Main', 'someotherkey');
17             print $val . "\n";
18         }
19         0;
20         __DATA__
21         # a comment
22         [MainSection]
23         somekey=somevalue
24         someotherkey=42
25         someboolkey=true
26         listkey=1;1;2;3;5;8;13;21
27         localekey=Good Morning
28         localekey[it]=Buon giorno
29         localekey[es]=Buenas dias
30         localekey[fr]=Bonjour
31

DESCRIPTION

33       Glib::KeyFile lets you parse, edit or create files containing groups of
34       key-value pairs, which we call key files for lack of a better name.
35       Several freedesktop.org specifications use key files now, e.g the Desk‐
36       top Entry Specification and the Icon Theme Specification.
37
38       The syntax of key files is described in detail in the Desktop Entry
39       Specification, here is a quick summary: Key files consists of groups of
40       key-value pairs, interspersed with comments.
41

METHODS

43       keyfile = Glib::KeyFile->new
44
45       boolean = $key_file->get_boolean ($group_name, $key)
46
47           * $group_name (string)
48           * $key (string)
49
50           Retrieves a boolean value from $key inside $group_name.
51
52           May croak with a Glib::Error in $@ on failure.
53
54       list = $key_file->get_boolean_list ($group_name, $key)
55
56           * $group_name (string)
57           * $key (string)
58
59           Retrieves a list of booleans from $key inside $group_name.
60
61           May croak with a Glib::Error in $@ on failure.
62
63       $key_file->set_boolean_list ($group_name, $key, ...)
64
65           * $group_name (string)
66           * $key (string)
67           * ... (list) list of booleans
68
69           Sets a list of booleans in $key inside $group_name.  If $key cannot
70           be found then it is created.  If $group_name cannot be found then
71           it is created.
72
73       $key_file->set_boolean ($group_name, $key, $value)
74
75           * $group_name (string)
76           * $key (string)
77           * $value (boolean)
78
79           Sets a boolean value to $key inside $group_name.  If $key is not
80           found, it is created.
81
82       string = $key_file->get_comment ($group_name=undef, $key=undef)
83
84           * $group_name (string or undef)
85           * $key (string or undef)
86
87           Retreives a comment above $key from $group_name.  If $key is undef
88           then $comment will be read from above $group_name.  If both $key
89           and $group_name are undef, then $comment will be read from above
90           the first group in the file.
91
92           May croak with a Glib::Error in $@ on failure.
93
94       $key_file->set_comment ($group_name, $key, $comment)
95
96           * $group_name (string or undef)
97           * $key (string or undef)
98           * $comment (string)
99
100           Places a comment above $key from $group_name.  If $key is undef
101           then $comment will be written above $group_name.  If both $key and
102           $group_name are undef, then $comment will be written above the
103           first group in the file.
104
105           May croak with a Glib::Error in $@ on failure.
106
107       double = $key_file->get_double ($group_name, $key)
108
109           * $group_name (string)
110           * $key (string)
111
112           Retrieves a double value from $key inside $group_name.
113
114           May croak with a Glib::Error in $@ on failure.
115
116       list = $key_file->get_double_list ($group_name, $key)
117
118           * $group_name (string)
119           * $key (string)
120
121           Retrieves a list of doubles from $key inside $group_name.
122
123           May croak with a Glib::Error in $@ on failure.
124
125       $key_file->set_double_list ($group_name, $key, ...)
126
127           * $group_name (string)
128           * $key (string)
129           * ... (list) list of doubles
130
131           Sets a list of doubles in $key inside $group_name.  If $key cannot
132           be found then it is created.  If $group_name cannot be found then
133           it is created.
134
135       $key_file->set_double ($group_name, $key, $value)
136
137           * $group_name (string)
138           * $key (string)
139           * $value (double)
140
141           Sets a double value to $key inside $group_name.  If $key is not
142           found, it is created.
143
144       list = $key_file->get_groups
145
146           Returns the list of groups inside the key_file.
147
148       boolean = $key_file->has_group ($group_name)
149
150           * $group_name (string)
151
152           Checks whether $group_name is present in $key_file.
153
154       boolean = $key_file->has_key ($group_name, $key)
155
156           * $group_name (string)
157           * $key (string)
158
159           Checks whether $group_name has $key in it.
160
161           May croak with a Glib::Error in $@ on failure.
162
163       integer = $key_file->get_integer ($group_name, $key)
164
165           * $group_name (string)
166           * $key (string)
167
168           Retrieves an integer value from $key inside $group_name.
169
170           May croak with a Glib::Error in $@ on failure.
171
172       list = $key_file->get_integer_list ($group_name, $key)
173
174           * $group_name (string)
175           * $key (string)
176
177           Retrieves a list of integers from $key inside $group_name.
178
179           May croak with a Glib::Error in $@ on failure.
180
181       $key_file->set_integer_list ($group_name, $key, ...)
182
183           * $group_name (string)
184           * $key (string)
185           * ... (list) list of integers
186
187           Sets a list of doubles in $key inside $group_name.  If $key cannot
188           be found then it is created.  If $group_name cannot be found then
189           it is created.
190
191       $key_file->set_integer ($group_name, $key, $value)
192
193           * $group_name (string)
194           * $key (string)
195           * $value (integer)
196
197           Sets an integer value to $key inside $group_name.  If $key is not
198           found, it is created.
199
200       list = $key_file->get_keys ($group_name)
201
202           * $group_name (string)
203
204           Returns the list of keys inside a group of the key file.
205
206           May croak with a Glib::Error in $@ on failure.
207
208       $key_file->set_list_separator ($separator)
209
210           * $separator (string)
211
212           Sets the list separator character.
213
214       boolean = $key_file->load_from_data ($buf, $flags)
215
216           * $buf (scalar)
217           * $flags (Glib::KeyFileFlags)
218
219           Parses a string containing a key file structure.
220
221           May croak with a Glib::Error in $@ on failure.
222
223       boolean = $key_file->load_from_data_dirs ($file, $flags)
224
225       (boolean, scalar) = $key_file->load_from_data_dirs ($file, $flags)
226
227           * $file (string)
228           * $flags (Glib::KeyFileFlags)
229
230           Parses a key file, searching for it inside the data directories.
231           In scalar context, it returns a boolean value (true on success,
232           false otherwise); in array context, it returns a boolean value and
233           the full path of the file.
234
235           May croak with a Glib::Error in $@ on failure.
236
237       boolean = $key_file->load_from_file ($file, $flags)
238
239           * $file (string)
240           * $flags (Glib::KeyFileFlags)
241
242           Parses a key file.
243
244           May croak with a Glib::Error in $@ on failure.
245
246       string = $key_file->get_locale_string ($group_name, $key,
247       $locale=undef)
248
249           * $group_name (string)
250           * $key (string)
251           * $locale (string or undef)
252
253           Returns the value associated with $key under $group_name translated
254           in the given $locale if available.  If $locale is undef then the
255           current locale is assumed.
256
257           May croak with a Glib::Error in $@ on failure.
258
259       list = $key_file->get_locale_string_list ($group_name, $key, $locale)
260
261           * $group_name (string)
262           * $key (string)
263           * $locale (string)
264
265           May croak with a Glib::Error in $@ on failure.
266
267       $key_file->set_locale_string_list ($group_name, $key, $locale, ...)
268
269           * $group_name (string)
270           * $key (string)
271           * $locale (string)
272           * ... (list)
273
274           Associates a list of string values for $key and $locale under
275           $group_name.  If the translation for $key cannot be found then it
276           is created.
277
278       $key_file->set_locale_string ($group_name, $key, $locale, $string)
279
280           * $group_name (string)
281           * $key (string)
282           * $locale (string)
283           * $string (string)
284
285       $key_file->remove_comment ($group_name=undef, $key=undef)
286
287           * $group_name (string or undef)
288           * $key (string or undef)
289
290           Removes a comment from a group in a key file.  If $key is undef,
291           the comment will be removed from above $group_name.  If both $key
292           and $group_name are undef, the comment will be removed from the top
293           of the key file.
294
295           May croak with a Glib::Error in $@ on failure.
296
297       $key_file->remove_group ($group_name)
298
299           * $group_name (string)
300
301           Removes a group from a key file.
302
303           May croak with a Glib::Error in $@ on failure.
304
305       $key_file->remove_key ($group_name, $key)
306
307           * $group_name (string)
308           * $key (string)
309
310           Removes a key from $group_name.
311
312           May croak with a Glib::Error in $@ on failure.
313
314       string = $key_file->get_start_group
315
316           Returns the first group inside a key file.
317
318       string = $key_file->get_string ($group_name, $key)
319
320           * $group_name (string)
321           * $key (string)
322
323           Retrieves a string value from $key inside $group_name.
324
325           May croak with a Glib::Error in $@ on failure.
326
327       list = $key_file->get_string_list ($group_name, $key)
328
329           * $group_name (string)
330           * $key (string)
331
332           Retrieves a list of strings from $key inside $group_name.
333
334           May croak with a Glib::Error in $@ on failure.
335
336       $key_file->set_string_list ($group_name, $key, ...)
337
338           * $group_name (string)
339           * $key (string)
340           * ... (list) list of strings
341
342           Sets a list of strings in $key inside $group_name.  The strings
343           will be escaped if contain special characters.  If $key cannot be
344           found then it is created.  If $group_name cannot be found then it
345           is created.
346
347       $key_file->set_string ($group_name, $key, $value)
348
349           * $group_name (string)
350           * $key (string)
351           * $value (string)
352
353           Sets a string value to $key inside $group_name.  The string will be
354           escaped if it containes special characters.  If $key is not found,
355           it is created.
356
357       string = $key_file->to_data
358
359           Returns the key file as a string.
360
361           May croak with a Glib::Error in $@ on failure.
362
363       string = $key_file->get_value ($group_name, $key)
364
365           * $group_name (string)
366           * $key (string)
367
368           Retrieves the literal value of $key inside $group_name.
369
370           May croak with a Glib::Error in $@ on failure.
371
372       $key_file->set_value ($group_name, $key, $value)
373
374           * $group_name (string)
375           * $key (string)
376           * $value (string)
377
378           Sets the literal value of $key inside $group_name.  If $key cannot
379           be found, it is created.  If $group_name cannot be found, it is
380           created.
381

ENUMS AND FLAGS

383       flags Glib::KeyFileFlags
384
385       * 'none' / 'G_KEY_FILE_NONE'
386       * 'keep-comments' / 'G_KEY_FILE_KEEP_COMMENTS'
387       * 'keep-translations' / 'G_KEY_FILE_KEEP_TRANSLATIONS'
388

SEE ALSO

390       Glib
391
393       Copyright (C) 2003-2007 by the gtk2-perl team.
394
395       This software is licensed under the LGPL.  See Glib for a full notice.
396
397
398
399perl v5.8.8                       2007-02-26                  Glib::KeyFile(3)
Impressum