logo top
Main Page   Widgets   glibmm Namespaces   Book  

Glib::KeyFile Class Reference

List of all members.

Public Member Functions

 KeyFile ()
 Creates a new, empty KeyFile object.
 ~KeyFile ()
 Destructor.
 KeyFile (GKeyFile* castitem, bool takes_ownership=false)
 Creates a glibmm KeyFile wrapper for a GKeyFile object.
bool load_from_file (const std::string& filename, KeyFileFlags flags=Glib::KEY_FILE_NONE)
 Loads a key file into an empty G::KeyFile structure.
bool load_from_data (const Glib::ustring& data, KeyFileFlags flags=Glib::KEY_FILE_NONE)
 Loads a KeyFile from memory.
bool load_from_data_dirs (const std::string& file, std::string& full_path, KeyFileFlags flags=Glib::KEY_FILE_NONE)
 Looks for a KeyFile named file in the paths returned from g_get_user_data_dir() and g_get_system_data_dirs() and loads them into the keyfile object, placing the full path to the file in full_path.
Glib::ustring to_data ()
 Outputs the KeyFile as a string.
Glib::ustring get_start_group () const
 Returns the name of the start group of the file.
Glib::ArrayHandle<Glib::ustringget_groups () const
 Gets a list of all groups in the KeyFile.
Glib::ArrayHandle<Glib::ustringget_keys (const Glib::ustring& group_name) const
 Gets a list of all keys from the group group_name.
bool has_group (const Glib::ustring& group_name) const
 Looks whether the key file has the group group_name .
bool has_key (const Glib::ustring& group_name, const Glib::ustring& key) const
 Looks whether the key file has the key key in the group group_name .
Glib::ustring get_value (const Glib::ustring& group_name, const Glib::ustring& key) const
 Returns the value associated with key under group_name .
Glib::ustring get_string (const Glib::ustring& group_name, const Glib::ustring& key) const
 Returns the value associated with key under group_name .
Glib::ustring get_locale_string (const Glib::ustring& group_name, const Glib::ustring& key) const
 Gets the value associated with key under group_name translated into the current locale.
Glib::ustring get_locale_string (const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& locale) const
 Returns the value associated with key under group_name translated in the given locale if available.
bool get_boolean (const Glib::ustring& group_name, const Glib::ustring& key) const
 Returns the value associated with key under group_name as a boolean.
int get_integer (const Glib::ustring& key) const
 Gets the value in the first group, under key, interpreting it as an integer.
int get_integer (const Glib::ustring& group_name, const Glib::ustring& key) const
 Returns the value associated with key under group_name as an integer.
Glib::ArrayHandle<Glib::ustringget_string_list (const Glib::ustring& group_name, const Glib::ustring& key) const
 Returns the values associated with key under group_name.
Glib::ArrayHandle<Glib::ustringget_locale_string_list (const Glib::ustring& group_name, const Glib::ustring& key) const
 Returns the values associated with key under group_name translated into the current locale, if available.
Glib::ArrayHandle<Glib::ustringget_locale_string_list (const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& locale) const
 Returns the values associated with key under group_name translated into locale, if available.
Glib::ArrayHandle<bool> get_boolean_list (const Glib::ustring& group_name, const Glib::ustring& key) const
 Returns the values associated with key under group_name.
Glib::ArrayHandle<int> get_integer_list (const Glib::ustring& group_name, const Glib::ustring& key) const
 Returns the values associated with key under group_name.
Glib::ustring get_comment () const
 Get comment from top of file.
Glib::ustring get_comment (const Glib::ustring& group_name) const
 Get comment from above a group.
Glib::ustring get_comment (const Glib::ustring& group_name, const Glib::ustring& key) const
 Retrieves a comment above key from group_name .
void set_list_separator (gchar separator)
 Sets the character which is used to separate values in lists.
void set_value (const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& value)
 Associates a new value with key under group_name .
void set_string (const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& string)
 Associates a new string value with key under group_name .
void set_locale_string (const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& locale, const Glib::ustring& string)
 Associates a string value for key and locale under group_name .
void set_boolean (const Glib::ustring& group_name, const Glib::ustring& key, bool value)
 Associates a new boolean value with key under group_name .
void set_integer (const Glib::ustring& group_name, const Glib::ustring& key, int value)
 Associates a new integer value with key under group_name .
void set_string_list (const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle<Glib::ustring>& list)
 Sets a list of string values for key under group_name.
void set_locale_string_list (const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& locale, const Glib::ArrayHandle<Glib::ustring>& list)
 Sets a list of string values for the key under group_name and marks them as being for locale.
void set_boolean_list (const Glib::ustring& group_name, const Glib::ustring& key, Glib::ArrayHandle<bool>& list)
 Sets a list of booleans for the key under group_name.
void set_integer_list (const Glib::ustring& group_name, const Glib::ustring& key, Glib::ArrayHandle<int>& list)
 Sets a list of integers for the key under group_name.
void set_comment (const Glib::ustring& comment)
 Places comment at the start of the file, before the first group.
void set_comment (const Glib::ustring& group_name, const Glib::ustring& comment)
 Places comment above group_name.
void set_comment (const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ustring& comment)
 Places a comment above key from group_name .
void remove_comment (const Glib::ustring& group_name, const Glib::ustring& key)
 Removes a comment above key from group_name .
void remove_key (const Glib::ustring& group_name, const Glib::ustring& key)
 Removes key in group_name from the key file.
void remove_group (const Glib::ustring& group_name)
 Removes the specified group, group_name , from the key file.
GKeyFile* gobj ()
const GKeyFile* gobj () const

Protected Attributes

GKeyFile* gobject_
bool owns_gobject_

Constructor & Destructor Documentation

Glib::KeyFile::KeyFile (  ) 

Creates a new, empty KeyFile object.

Glib::KeyFile::~KeyFile (  ) 

Destructor.

Glib::KeyFile::KeyFile ( GKeyFile *  castitem,
bool  takes_ownership = false 
)

Creates a glibmm KeyFile wrapper for a GKeyFile object.

Note, when using this that when the wrapper is deleted, it will not automatically deleted the GKeyFile unless you set the delete_c_instance boolean to true.

Parameters:
castitem The C instance to wrap
delete_c_instance If the C instance should be deleted when the wrapper is deleted.


Member Function Documentation

bool Glib::KeyFile::load_from_file ( const std::string filename,
KeyFileFlags  flags = Glib::KEY_FILE_NONE 
)

Loads a key file into an empty G::KeyFile structure.

If the file could not be loaded then error is set to either a G::FileError or G::KeyFileError.

Parameters:
file The path of a filename to load, in the GLib file name encoding.
flags Flags from G::KeyFileFlags.
error Return location for a G::Error, or 0.
Returns:
true if a key file could be loaded, false othewise
Since glibmm 2.6:

bool Glib::KeyFile::load_from_data ( const Glib::ustring data,
KeyFileFlags  flags = Glib::KEY_FILE_NONE 
)

Loads a KeyFile from memory.

Parameters:
data The data to use as a KeyFile
flags Bitwise combination of the flags to use for the KeyFile
Returns:
true if the KeyFile was successfully loaded, false otherwise
Exceptions:
Glib::KeyFileError 

bool Glib::KeyFile::load_from_data_dirs ( const std::string file,
std::string full_path,
KeyFileFlags  flags = Glib::KEY_FILE_NONE 
)

Looks for a KeyFile named file in the paths returned from g_get_user_data_dir() and g_get_system_data_dirs() and loads them into the keyfile object, placing the full path to the file in full_path.

Parameters:
file The file to search for
full_path Return location for a string containing the full path of the file
flags Bitwise combination of the flags to use for the KeyFile
Returns:
true if the KeyFile was successfully loaded, false otherwise
Exceptions:
Glib::KeyFileError 
Glib::FileError 

Glib::ustring Glib::KeyFile::to_data (  ) 

Outputs the KeyFile as a string.

Returns:
A string object holding the contents of KeyFile

Glib::ustring Glib::KeyFile::get_start_group (  )  const

Returns the name of the start group of the file.

Returns:
The start group of the key file.
Since glibmm 2.6:

Glib::ArrayHandle<Glib::ustring> Glib::KeyFile::get_groups (  )  const

Gets a list of all groups in the KeyFile.

Returns:
A list containing the names of the groups

Glib::ArrayHandle<Glib::ustring> Glib::KeyFile::get_keys ( const Glib::ustring group_name  )  const

Gets a list of all keys from the group group_name.

Parameters:
group_name The name of a group
Returns:
A list containing the names of the keys in group_name

bool Glib::KeyFile::has_group ( const Glib::ustring group_name  )  const

Looks whether the key file has the group group_name .

Parameters:
group_name A group name.
Returns:
true if group_name is a part of key_file , false otherwise.
Since glibmm 2.6:

bool Glib::KeyFile::has_key ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Looks whether the key file has the key key in the group group_name .

Parameters:
group_name A group name.
key A key name.
error Return location for a G::Error.
Returns:
true if key is a part of group_name , false otherwise.
Since glibmm 2.6:

Glib::ustring Glib::KeyFile::get_value ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Returns the value associated with key under group_name .

In the event the key cannot be found, 0 is returned and error is set to G::KEY_FILE_ERROR_KEY_NOT_FOUND. In the event that the group_name cannot be found, 0 is returned and error is set to G::KEY_FILE_ERROR_GROUP_NOT_FOUND.

Parameters:
group_name A group name.
key A key.
error Return location for a G::Error, or 0.
Returns:
A newly allocated string or 0 if the specified key cannot be found.
Since glibmm 2.6:

Glib::ustring Glib::KeyFile::get_string ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Returns the value associated with key under group_name .

In the event the key cannot be found, 0 is returned and error is set to G::KEY_FILE_ERROR_KEY_NOT_FOUND. In the event that the group_name cannot be found, 0 is returned and error is set to G::KEY_FILE_ERROR_GROUP_NOT_FOUND.

Parameters:
group_name A group name.
key A key.
error Return location for a G::Error, or 0.
Returns:
A newly allocated string or 0 if the specified key cannot be found.
Since glibmm 2.6:

Glib::ustring Glib::KeyFile::get_locale_string ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Gets the value associated with key under group_name translated into the current locale.

Glib::ustring Glib::KeyFile::get_locale_string ( const Glib::ustring group_name,
const Glib::ustring key,
const Glib::ustring locale 
) const

Returns the value associated with key under group_name translated in the given locale if available.

If locale is 0 then the current locale is assumed.

If key cannot be found then 0 is returned and error is set to G::KEY_FILE_ERROR_KEY_NOT_FOUND. If the value associated with key cannot be interpreted or no suitable translation can be found then the untranslated value is returned.

Parameters:
group_name A group name.
key A key.
locale A locale or 0.
error Return location for a G::Error, or 0.
Returns:
A newly allocated string or 0 if the specified key cannot be found.
Since glibmm 2.6:

bool Glib::KeyFile::get_boolean ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Returns the value associated with key under group_name as a boolean.

If key cannot be found then the return value is undefined and error is set to G::KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated with key cannot be interpreted as a boolean then the return value is also undefined and error is set to G::KEY_FILE_ERROR_INVALID_VALUE.

Parameters:
group_name A group name.
key A key.
error Return location for a G::Error.
Returns:
The value associated with the key as a boolean
Since glibmm 2.6:

int Glib::KeyFile::get_integer ( const Glib::ustring key  )  const

Gets the value in the first group, under key, interpreting it as an integer.

Parameters:
key The name of the key
Returns:
The value of key as an integer
Exceptions:
Glib::KeyFileError 

int Glib::KeyFile::get_integer ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Returns the value associated with key under group_name as an integer.

If group_name is 0, the start_group is used.

If key cannot be found then the return value is undefined and error is set to G::KEY_FILE_ERROR_KEY_NOT_FOUND. Likewise, if the value associated with key cannot be interpreted as an integer then the return value is also undefined and error is set to G::KEY_FILE_ERROR_INVALID_VALUE.

Parameters:
group_name A group name.
key A key.
error Return location for a G::Error.
Returns:
The value associated with the key as an integer.
Since glibmm 2.6:

Glib::ArrayHandle<Glib::ustring> Glib::KeyFile::get_string_list ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Returns the values associated with key under group_name.

Parameters:
group_name The name of a group
key The name of a key
Returns:
A list containing the values requested
Exceptions:
Glib::KeyFileError 

Glib::ArrayHandle<Glib::ustring> Glib::KeyFile::get_locale_string_list ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Returns the values associated with key under group_name translated into the current locale, if available.

Parameters:
group_name The name of a group
key The name of a key
Returns:
A list containing the values requested
Exceptions:
Glib::KeyFileError 

Glib::ArrayHandle<Glib::ustring> Glib::KeyFile::get_locale_string_list ( const Glib::ustring group_name,
const Glib::ustring key,
const Glib::ustring locale 
) const

Returns the values associated with key under group_name translated into locale, if available.

Parameters:
group_name The name of a group
key The name of a key
locale The name of a locale
Returns:
A list containing the values requested
Exceptions:
Glib::KeyFileError 

Glib::ArrayHandle<bool> Glib::KeyFile::get_boolean_list ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Returns the values associated with key under group_name.

Parameters:
group_name The name of a group
key The name of a key
Returns:
A list of booleans
Exceptions:
Glib::KeyFileError 

Glib::ArrayHandle<int> Glib::KeyFile::get_integer_list ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Returns the values associated with key under group_name.

Parameters:
group_name The name of a group
key The name of a key
Returns:
A list of integers
Exceptions:
Glib::KeyFileError 

Glib::ustring Glib::KeyFile::get_comment (  )  const

Get comment from top of file.

Returns:
The comment

Glib::ustring Glib::KeyFile::get_comment ( const Glib::ustring group_name  )  const

Get comment from above a group.

Parameters:
group_name The group
Returns:
The comment

Glib::ustring Glib::KeyFile::get_comment ( const Glib::ustring group_name,
const Glib::ustring key 
) const

Retrieves a comment above key from group_name .

group_name . If key is 0 then comment will be read from above group_name . If both key and group_name are 0, then comment will be read from above the first group in the file.

Parameters:
group_name A group name, or 0.
key A key.
error Return location for a G::Error.
Returns:
A comment that should be freed with g_free()
Since glibmm 2.6:

void Glib::KeyFile::set_list_separator ( gchar  separator  ) 

Sets the character which is used to separate values in lists.

Typically ';' or ',' are used as separators. The default list separator is ';'.

Since glibmm 2.6:
Parameters:
separator The separator.

void Glib::KeyFile::set_value ( const Glib::ustring group_name,
const Glib::ustring key,
const Glib::ustring value 
)

Associates a new value with key under group_name .

If key cannot be found then it is created. If group_name cannot be found then it is created.

Since glibmm 2.6:
Parameters:
group_name A group name.
key A key.
value A string.

void Glib::KeyFile::set_string ( const Glib::ustring group_name,
const Glib::ustring key,
const Glib::ustring string 
)

Associates a new string value with key under group_name .

If key cannot be found then it is created. If group_name cannot be found then it is created.

Since glibmm 2.6:
Parameters:
group_name A group name.
key A key.
string A string.

void Glib::KeyFile::set_locale_string ( const Glib::ustring group_name,
const Glib::ustring key,
const Glib::ustring locale,
const Glib::ustring string 
)

Associates a string value for key and locale under group_name .

If the translation for key cannot be found then it is created.

Since glibmm 2.6:
Parameters:
group_name A group name.
key A key.
locale A locale.
string A string.

void Glib::KeyFile::set_boolean ( const Glib::ustring group_name,
const Glib::ustring key,
bool  value 
)

Associates a new boolean value with key under group_name .

If key cannot be found then it is created.

Since glibmm 2.6:
Parameters:
group_name A group name.
key A key.
value true or false.

void Glib::KeyFile::set_integer ( const Glib::ustring group_name,
const Glib::ustring key,
int  value 
)

Associates a new integer value with key under group_name .

If key cannot be found then it is created.

Since glibmm 2.6:
Parameters:
group_name A group name.
key A key.
value An integer value.

void Glib::KeyFile::set_string_list ( const Glib::ustring group_name,
const Glib::ustring key,
const Glib::ArrayHandle<Glib::ustring>&  list 
)

Sets a list of string values for key under group_name.

If key cannot be found it is created. If group_name cannot be found it is created.

Parameters:
group_name The name of a group
key The name of a key
list A list holding objects of type Glib::ustring

void Glib::KeyFile::set_locale_string_list ( const Glib::ustring group_name,
const Glib::ustring key,
const Glib::ustring locale,
const Glib::ArrayHandle<Glib::ustring>&  list 
)

Sets a list of string values for the key under group_name and marks them as being for locale.

If the key or group_name cannot be found, they are created.

Parameters:
group_name The name of a group
key The name of a key
locale A locale
list A list holding objects of type Glib::ustring

void Glib::KeyFile::set_boolean_list ( const Glib::ustring group_name,
const Glib::ustring key,
Glib::ArrayHandle<bool>&  list 
)

Sets a list of booleans for the key under group_name.

If either the key or group_name cannot be found they are created

Parameters:
group_name The name of a group
key The name of a key
list A list holding object of type bool

void Glib::KeyFile::set_integer_list ( const Glib::ustring group_name,
const Glib::ustring key,
Glib::ArrayHandle<int>&  list 
)

Sets a list of integers for the key under group_name.

If either the key or group_name cannot be found they are created

Parameters:
group_name The name of a group
key The name of a key
list A list holding object of type int

void Glib::KeyFile::set_comment ( const Glib::ustring comment  ) 

Places comment at the start of the file, before the first group.

Parameters:
comment The Comment

void Glib::KeyFile::set_comment ( const Glib::ustring group_name,
const Glib::ustring comment 
)

Places comment above group_name.

Parameters:
group_name The Group the comment should be above
comment The comment

void Glib::KeyFile::set_comment ( const Glib::ustring group_name,
const Glib::ustring key,
const Glib::ustring comment 
)

Places a comment above key from group_name .

group_name . If key is 0 then comment will be written above group_name . If both key and group_name are 0, then comment will be written above the first group in the file.

Since glibmm 2.6:
Parameters:
group_name A group name, or 0.
key A key.
comment A comment.
error Return location for a G::Error.

void Glib::KeyFile::remove_comment ( const Glib::ustring group_name,
const Glib::ustring key 
)

Removes a comment above key from group_name .

group_name . If key is 0 then comment will be written above group_name . If both key and group_name are 0, then comment will be written above the first group in the file.

Since glibmm 2.6:
Parameters:
group_name A group name, or 0.
key A key.
error Return location for a G::Error.

void Glib::KeyFile::remove_key ( const Glib::ustring group_name,
const Glib::ustring key 
)

Removes key in group_name from the key file.

Since glibmm 2.6:
Parameters:
group_name A group name.
key A key name to remove.
error Return location for a G::Error or 0.

void Glib::KeyFile::remove_group ( const Glib::ustring group_name  ) 

Removes the specified group, group_name , from the key file.

Since glibmm 2.6:
Parameters:
group_name A group name.
error Return location for a G::Error or 0.

GKeyFile* Glib::KeyFile::gobj (  )  [inline]

const GKeyFile* Glib::KeyFile::gobj (  )  const [inline]


Member Data Documentation

GKeyFile* Glib::KeyFile::gobject_ [protected]

bool Glib::KeyFile::owns_gobject_ [protected]


The documentation for this class was generated from the following file:
Generated for glibmm 2.4 by Doxygen 1.5.1 © 1997-2001