Codex

Glib::KeyFile

Section: User Contributed Perl Documentation (3pm)

Updated: 2014-08-29

Index?action=index Return to Main Contents


NAME

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

SYNOPSIS

DESCRIPTION

Glib::KeyFile lets you parse, edit or create files containing groups of key-value pairs, which we call key files for lack of a better name. Several freedesktop.org specifications use key files now, e.g the Desktop Entry Specification and the Icon Theme Specification.

The syntax of key files is described in detail in the Desktop Entry Specification, here is a quick summary: Key files consists of groups of key-value pairs, interspersed with comments.

METHODS

keyfile = Glib::KeyFile->new

boolean = $key_file->get_boolean ($group_name, $key)

(string):
(string):
Retrieves a boolean value from inside .

May croak with a Glib::Error in [email protected] on failure.

list = $key_file->get_boolean_list ($group_name, $key)

(string):
(string):
Retrieves a list of booleans from inside .

May croak with a Glib::Error in [email protected] on failure.

$key_file->set_boolean_list ($group_name, $key, ...)

(string):
(string):
... (list) list of booleans:
Sets a list of booleans in inside . If cannot be found then it is created. If cannot be found then it is created.

$key_file->set_boolean ($group_name, $key, $value)

(string):
(string):
(boolean):
Sets a boolean value to inside . If is not found, it is created.

string = $key_file->get_comment ($group_name=undef, $key=undef)

(string or undef):
(string or undef):
Retreives a comment above from . If is undef then will be read from above . If both and are undef, then will be read from above the first group in the file.

May croak with a Glib::Error in [email protected] on failure.

$key_file->set_comment ($group_name, $key, $comment)

(string or undef):
(string or undef):
(string):
Places a comment above from . If is undef then will be written above . If both and are undef, then will be written above the first group in the file.

May croak with a Glib::Error in [email protected] on failure.

double = $key_file->get_double ($group_name, $key)

(string):
(string):
Retrieves a double value from inside .

May croak with a Glib::Error in [email protected] on failure.

Since: glib 2.12

list = $key_file->get_double_list ($group_name, $key)

(string):
(string):
Retrieves a list of doubles from inside .

May croak with a Glib::Error in [email protected] on failure.

Since: glib 2.12

$key_file->set_double_list ($group_name, $key, ...)

(string):
(string):
... (list) list of doubles:
Sets a list of doubles in inside . If cannot be found then it is created. If cannot be found then it is created.

Since: glib 2.12

$key_file->set_double ($group_name, $key, $value)

(string):
(string):
(double):
Sets a double value to inside . If is not found, it is created.

Since: glib 2.12

list = $key_file->get_groups

Returns the list of groups inside the key_file.

boolean = $key_file->has_group ($group_name)

(string):
Checks whether is present in .

boolean = $key_file->has_key ($group_name, $key)

(string):
(string):
Checks whether has in it.

May croak with a Glib::Error in [email protected] on failure.

integer = $key_file->get_integer ($group_name, $key)

(string):
(string):
Retrieves an integer value from inside .

May croak with a Glib::Error in [email protected] on failure.

list = $key_file->get_integer_list ($group_name, $key)

(string):
(string):
Retrieves a list of integers from inside .

May croak with a Glib::Error in [email protected] on failure.

$key_file->set_integer_list ($group_name, $key, ...)

(string):
(string):
... (list) list of integers:
Sets a list of doubles in inside . If cannot be found then it is created. If cannot be found then it is created.

$key_file->set_integer ($group_name, $key, $value)

(string):
(string):
(integer):
Sets an integer value to inside . If is not found, it is created.

list = $key_file->get_keys ($group_name)

(string):

Returns the list of keys inside a group of the key file.

May croak with a Glib::Error in [email protected] on failure.

$key_file->set_list_separator ($separator)

(string):

Sets the list separator character.

boolean = $key_file->load_from_data ($buf, $flags)

(scalar):
(Glib::KeyFileFlags):

Parses a string containing a key file structure.

May croak with a Glib::Error in [email protected] on failure.

boolean = $key_file->load_from_data_dirs ($file, $flags)

(boolean, scalar) = $key_file->load_from_data_dirs ($file, $flags)

(string):
(Glib::KeyFileFlags):

Parses a key file, searching for it inside the data directories. In scalar context, it returns a boolean value (true on success, false otherwise); in array context, it returns a boolean value and the full path of the file.

May croak with a Glib::Error in [email protected] on failure.

boolean = $key_file->load_from_dirs ($file, $flags, @search_dirs)

(boolean, scalar) = $key_file->load_from_dirs ($file, $flags, @search_dirs)

(string):
(Glib::KeyFileFlags):
... (list):

Parses a key file, searching for it inside the specified directories. In scalar context, it returns a boolean value (true on success, false otherwise); in array context, it returns a boolean value and the full path of the file.

May croak with a Glib::Error in [email protected] on failure.

Since: glib 2.14

boolean = $key_file->load_from_file ($file, $flags)

(string):
(Glib::KeyFileFlags):

Parses a key file.

May croak with a Glib::Error in [email protected] on failure.

string = $key_file->get_locale_string ($group_name, $key, $locale=undef)

(string):
(string):
(string or undef):
Returns the value associated with under translated in the given if available. If is undef then the current locale is assumed.

May croak with a Glib::Error in [email protected] on failure.

list = $key_file->get_locale_string_list ($group_name, $key, $locale)

(string):
(string):
(string):

May croak with a Glib::Error in [email protected] on failure.

$key_file->set_locale_string_list ($group_name, $key, $locale, ...)

(string):
(string):
(string):
... (list):
Associates a list of string values for and under . If the translation for cannot be found then it is created.

$key_file->set_locale_string ($group_name, $key, $locale, $string)

(string):
(string):
(string):
(string):

$key_file->remove_comment ($group_name=undef, $key=undef)

(string or undef):
(string or undef):
Removes a comment from a group in a key file. If is undef, the comment will be removed from above . If both and are undef, the comment will be removed from the top of the key file.

May croak with a Glib::Error in [email protected] on failure.

$key_file->remove_group ($group_name)

(string):

Removes a group from a key file.

May croak with a Glib::Error in [email protected] on failure.

$key_file->remove_key ($group_name, $key)

(string):
(string):
Removes a key from .

May croak with a Glib::Error in [email protected] on failure.

string = $key_file->get_start_group

Returns the first group inside a key file.

string = $key_file->get_string ($group_name, $key)

(string):
(string):
Retrieves a string value from inside .

May croak with a Glib::Error in [email protected] on failure.

list = $key_file->get_string_list ($group_name, $key)

(string):
(string):
Retrieves a list of strings from inside .

May croak with a Glib::Error in [email protected] on failure.

$key_file->set_string_list ($group_name, $key, ...)

(string):
(string):
... (list) list of strings:
Sets a list of strings in inside . The strings will be escaped if contain special characters. If cannot be found then it is created. If cannot be found then it is created.

$key_file->set_string ($group_name, $key, $value)

(string):
(string):
(string):
Sets a string value to inside . The string will be escaped if it contains special characters. If is not found, it is created.

string = $key_file->to_data

Returns the key file as a string.

May croak with a Glib::Error in [email protected] on failure.

string = $key_file->get_value ($group_name, $key)

(string):
(string):
Retrieves the literal value of inside .

May croak with a Glib::Error in [email protected] on failure.

$key_file->set_value ($group_name, $key, $value)

(string):
(string):
(string):
Sets the literal value of inside . If cannot be found, it is created. If cannot be found, it is created.

ENUMS AND FLAGS

flags Glib::KeyFileFlags

'none' / 'G_KEY_FILE_NONE':
'keep-comments' / 'G_KEY_FILE_KEEP_COMMENTS':
'keep-translations' / 'G_KEY_FILE_KEEP_TRANSLATIONS':

SEE ALSO

Glib

COPYRIGHT

Copyright (C) 2003-2011 by the gtk2-perl team.

This software is licensed under the LGPL. See Glib for a full notice.


Index

NAME

SYNOPSIS

DESCRIPTION

METHODS

keyfile = Glib::KeyFile->new

boolean = $key_file->get_boolean ($group_name, $key)

list = $key_file->get_boolean_list ($group_name, $key)

$key_file->set_boolean_list ($group_name, $key, ...)

$key_file->set_boolean ($group_name, $key, $value)

string = $key_file->get_comment ($group_name=undef, $key=undef)

$key_file->set_comment ($group_name, $key, $comment)

double = $key_file->get_double ($group_name, $key)

list = $key_file->get_double_list ($group_name, $key)

$key_file->set_double_list ($group_name, $key, ...)

$key_file->set_double ($group_name, $key, $value)

list = $key_file->get_groups

boolean = $key_file->has_group ($group_name)

boolean = $key_file->has_key ($group_name, $key)

integer = $key_file->get_integer ($group_name, $key)

list = $key_file->get_integer_list ($group_name, $key)

$key_file->set_integer_list ($group_name, $key, ...)

$key_file->set_integer ($group_name, $key, $value)

list = $key_file->get_keys ($group_name)

$key_file->set_list_separator ($separator)

boolean = $key_file->load_from_data ($buf, $flags)

boolean = $key_file->load_from_data_dirs ($file, $flags)

(boolean, scalar) = $key_file->load_from_data_dirs ($file, $flags)

boolean = $key_file->load_from_dirs ($file, $flags, @search_dirs)

(boolean, scalar) = $key_file->load_from_dirs ($file, $flags, @search_dirs)

boolean = $key_file->load_from_file ($file, $flags)

string = $key_file->get_locale_string ($group_name, $key, $locale=undef)

list = $key_file->get_locale_string_list ($group_name, $key, $locale)

$key_file->set_locale_string_list ($group_name, $key, $locale, ...)

$key_file->set_locale_string ($group_name, $key, $locale, $string)

$key_file->remove_comment ($group_name=undef, $key=undef)

$key_file->remove_group ($group_name)

$key_file->remove_key ($group_name, $key)

string = $key_file->get_start_group

string = $key_file->get_string ($group_name, $key)

list = $key_file->get_string_list ($group_name, $key)

$key_file->set_string_list ($group_name, $key, ...)

$key_file->set_string ($group_name, $key, $value)

string = $key_file->to_data

string = $key_file->get_value ($group_name, $key)

$key_file->set_value ($group_name, $key, $value)

ENUMS AND FLAGS

flags Glib::KeyFileFlags

SEE ALSO

COPYRIGHT


editar SideBar