glibmm 2.80.0
|
This class lets you parse, edit or create files containing groups of key-value pairs, which we call key files for lack of a better name. More...
#include <glibmm/keyfile.h>
Public Types | |
enum class | Flags { NONE = 0x0 , KEEP_COMMENTS = 1 << 0 , KEEP_TRANSLATIONS = 1 << 1 } |
Public Member Functions | |
void | reference () const |
Increment the reference count for this object. | |
void | unreference () const |
Decrement the reference count for this object. | |
GKeyFile * | gobj () |
Provides access to the underlying C instance. | |
const GKeyFile * | gobj () const |
Provides access to the underlying C instance. | |
GKeyFile * | gobj_copy () const |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. | |
KeyFile ()=delete | |
KeyFile (const KeyFile &)=delete | |
KeyFile & | operator= (const KeyFile &)=delete |
bool | load_from_file (const std::string & file, Flags flags=Flags::NONE) |
Loads a key file into an empty KeyFile instance. | |
bool | load_from_data (const Glib::ustring &data, Flags flags=Flags::NONE) |
Loads a KeyFile from memory. | |
bool | load_from_dirs (const std::string & file, const std::vector< std::string > &search_dirs, std::string &full_path, Flags flags=Flags::NONE) |
This function looks for a key file named file in the paths specified in search_dirs, loads the file into key_file and returns the file's full path in full_path. | |
bool | load_from_data_dirs (const std::string & file, std::string &full_path, Flags flags=Flags::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. | |
bool | save_to_file (const std::string &filename) |
Writes the contents of key_file to filename using g_file_set_contents(). | |
Glib::ustring | get_start_group () const |
Returns the name of the start group of the file. | |
std::vector< Glib::ustring > | get_groups () const |
Gets a list of all groups in the KeyFile. | |
std::vector< Glib::ustring > | get_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 |
Return value: a newly allocated string or nullptr . | |
Glib::ustring | get_locale_for_key (const Glib::ustring &group_name, const Glib::ustring & key, const Glib::ustring & locale={}) const |
Returns the actual locale which the result of g_key_file_get_locale_string() or g_key_file_get_locale_string_list() came from. | |
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 |
Return value: a newly allocated string or nullptr . | |
bool | get_boolean (const Glib::ustring & key) const |
Gets the value in the first group, under key, interpreting it as a boolean. | |
bool | get_boolean (const Glib::ustring &group_name, const Glib::ustring & key) const |
Return value: the value associated with the key 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 |
Return value: the value associated with the key as an integer. | |
gint64 | get_int64 (const Glib::ustring & key) const |
Gets the value in the first group, under key, interpreting it as a signed 64-bit integer. | |
gint64 | get_int64 (const Glib::ustring &group_name, const Glib::ustring & key) const |
Returns the value associated with key under group_name as a signed 64-bit integer. | |
guint64 | get_uint64 (const Glib::ustring & key) const |
Gets the value in the first group, under key, interpreting it as an unsigned 64-bit integer. | |
guint64 | get_uint64 (const Glib::ustring &group_name, const Glib::ustring & key) const |
Returns the value associated with key under group_name as an unsigned 64-bit integer. | |
double | get_double (const Glib::ustring & key) const |
Gets the value in the first group, under key, interpreting it as a double. | |
double | get_double (const Glib::ustring &group_name, const Glib::ustring & key) const |
Return value: the value associated with the key as a double. | |
void | set_double (const Glib::ustring &group_name, const Glib::ustring & key, double value) |
Associates a new double value with key under group_name. | |
void | set_double (const Glib::ustring & key, double value) |
Associates a new double value with key under the start group. | |
std::vector< Glib::ustring > | get_string_list (const Glib::ustring &group_name, const Glib::ustring & key) const |
Returns the values associated with key under group_name. | |
std::vector< Glib::ustring > | 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. | |
std::vector< Glib::ustring > | 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. | |
std::vector< bool > | get_boolean_list (const Glib::ustring &group_name, const Glib::ustring & key) const |
Returns the values associated with key under group_name. | |
std::vector< int > | get_integer_list (const Glib::ustring &group_name, const Glib::ustring & key) const |
Returns the values associated with key under group_name. | |
std::vector< double > | get_double_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_int64 (const Glib::ustring &group_name, const Glib::ustring & key, gint64 value) |
Associates a new integer value with key under group_name. | |
void | set_uint64 (const Glib::ustring &group_name, const Glib::ustring & key, guint64 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 std::vector< 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 std::vector< 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, const std::vector< 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, const std::vector< int > & list) |
Sets a list of integers for the key under group_name. | |
void | set_double_list (const Glib::ustring &group_name, const Glib::ustring & key, const std::vector< double > & list) |
Sets a list of doubles 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. | |
Static Public Member Functions | |
static Glib::RefPtr< KeyFile > | create () |
Protected Member Functions | |
void | operator delete (void *, std::size_t) |
Related Symbols | |
(Note that these are not member symbols.) | |
Glib::RefPtr< Glib::KeyFile > | wrap (GKeyFile *object, bool take_copy=false) |
A Glib::wrap() method for this object. | |
This class 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.
Lines beginning with a '#' and blank lines are considered comments.
Groups are started by a header line containing the group name enclosed in '[' and ']', and ended implicitly by the start of the next group or the end of the file. Each key-value pair must be contained in a group.
Key-value pairs generally have the form key=value, with the exception of localized strings, which have the form key[locale]=value. Space before and after the '=' character are ignored. Newline, tab, carriage return and backslash characters in value are escaped as \n, \t, \r, and \\, respectively. To preserve leading spaces in values, these can also be escaped as \s.
Key files can store strings (possibly with localized variants), integers, booleans and lists of these. Lists are separated by a separator character, typically ';' or ','. To use the list separator character in a value in a list, it has to be escaped by prefixing it with a backslash.
This syntax is obviously inspired by the .ini files commonly met on Windows, but there are some important differences:
Note that in contrast to the Desktop Entry Specification, groups in key files may contain the same key multiple times; the last entry wins. Key files may also contain multiple groups with the same name; they are merged together. Another difference is that keys and group names in key files are not restricted to ASCII characters.
|
strong |
|
delete |
|
static |
bool Glib::KeyFile::get_boolean | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key | ||
) | const |
Return value: the value associated with the key as a boolean.
Glib::KeyFileError |
group_name | A group name. |
key | A key. |
false
if the key was not found or could not be parsed. bool Glib::KeyFile::get_boolean | ( | const Glib::ustring & | key | ) | const |
Gets the value in the first group, under key, interpreting it as a boolean.
key | The name of the key. |
Glib::KeyFileError. |
std::vector< 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.
group_name | The name of a group |
key | The name of a key |
Glib::KeyFileError |
Glib::ustring Glib::KeyFile::get_comment | ( | ) | const |
Glib::ustring Glib::KeyFile::get_comment | ( | const Glib::ustring & | group_name | ) | const |
Get comment from above a group.
group_name | The group |
Glib::KeyFileError |
Glib::ustring Glib::KeyFile::get_comment | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key | ||
) | const |
Retrieves a comment above key from group_name.
If key is nullptr
then comment will be read from above group_name. If both key and group_name are nullptr
, then comment will be read from above the first group in the file. Use the overrides for a nullptr
key or group.
Glib::KeyFileError |
group_name | A group name. |
key | A key. |
double Glib::KeyFile::get_double | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key | ||
) | const |
Return value: the value associated with the key as a double.
Glib::KeyFileError |
group_name | A group name. |
key | A key. |
double Glib::KeyFile::get_double | ( | const Glib::ustring & | key | ) | const |
Gets the value in the first group, under key, interpreting it as a double.
key | The name of the key |
Glib::KeyFileError |
std::vector< double > Glib::KeyFile::get_double_list | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key | ||
) | const |
Returns the values associated with key under group_name.
group_name | The name of a group |
key | The name of a key |
Glib::KeyFileError |
std::vector< Glib::ustring > Glib::KeyFile::get_groups | ( | ) | const |
Gets a list of all groups in the KeyFile.
gint64 Glib::KeyFile::get_int64 | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key | ||
) | const |
Returns the value associated with key under group_name as a signed 64-bit integer.
This is similar to g_key_file_get_integer() but can return 64-bit results without truncation.
group_name | A non-nullptr group name. |
key | A non-nullptr key. |
Glib::KeyFileError |
gint64 Glib::KeyFile::get_int64 | ( | const Glib::ustring & | key | ) | const |
Gets the value in the first group, under key, interpreting it as a signed 64-bit integer.
This is similar to get_integer() but can return 64-bit results without truncation.
key | The name of the key. |
0
if the key was not found or could not be parsed. Glib::KeyFileError. |
int Glib::KeyFile::get_integer | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key | ||
) | const |
Return value: the value associated with the key as an integer.
Glib::KeyFileError |
group_name | A group name. |
key | A key. |
int Glib::KeyFile::get_integer | ( | const Glib::ustring & | key | ) | const |
Gets the value in the first group, under key, interpreting it as an integer.
key | The name of the key |
Glib::KeyFileError |
std::vector< 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.
group_name | The name of a group |
key | The name of a key |
Glib::KeyFileError |
std::vector< Glib::ustring > Glib::KeyFile::get_keys | ( | const Glib::ustring & | group_name | ) | const |
Gets a list of all keys from the group group_name.
group_name | The name of a group |
Glib::KeyFileError |
Glib::ustring Glib::KeyFile::get_locale_for_key | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key, | ||
const Glib::ustring & | locale = {} |
||
) | const |
Returns the actual locale which the result of g_key_file_get_locale_string() or g_key_file_get_locale_string_list() came from.
If calling g_key_file_get_locale_string() or g_key_file_get_locale_string_list() with exactly the same key_file, group_name, key and locale, the result of those functions will have originally been tagged with the locale that is the result of this function.
group_name | A group name. |
key | A key. |
locale | A locale identifier or nullptr . |
nullptr
if the key was not found or the entry in the file was was untranslated. 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::KeyFileError |
Glib::ustring Glib::KeyFile::get_locale_string | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key, | ||
const Glib::ustring & | locale | ||
) | const |
Return value: a newly allocated string or nullptr
.
Glib::KeyFileError |
group_name | A group name. |
key | A key. |
locale | A locale identifier or nullptr . |
nullptr
if the specified key cannot be found. std::vector< 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.
group_name | The name of a group |
key | The name of a key |
Glib::KeyFileError |
std::vector< 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.
group_name | The name of a group |
key | The name of a key |
locale | The name of a locale |
Glib::KeyFileError |
Glib::ustring Glib::KeyFile::get_start_group | ( | ) | const |
Returns the name of the start group of the file.
Glib::ustring Glib::KeyFile::get_string | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key | ||
) | const |
Return value: a newly allocated string or nullptr
.
Glib::KeyFileError |
group_name | A group name. |
key | A key. |
nullptr
if the specified key cannot be found. std::vector< 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.
group_name | The name of a group |
key | The name of a key |
Glib::KeyFileError |
guint64 Glib::KeyFile::get_uint64 | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key | ||
) | const |
Returns the value associated with key under group_name as an unsigned 64-bit integer.
This is similar to g_key_file_get_integer() but can return large positive results without truncation.
group_name | A non-nullptr group name. |
key | A non-nullptr key. |
Glib::KeyFileError |
guint64 Glib::KeyFile::get_uint64 | ( | const Glib::ustring & | key | ) | const |
Gets the value in the first group, under key, interpreting it as an unsigned 64-bit integer.
This is similar to get_integer() but can return large positive results without truncation.
key | The name of the key. |
0
if the key was not found or could not be parsed. Glib::KeyFileError. |
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.
Glib::KeyFileError | in the event the key cannot be found (with the Glib::KeyFileError::KEY_NOT_FOUND code). |
Glib::KeyFileError | in the event that the group_name cannot be found (with the Glib::KeyFileError::GROUP_NOT_FOUND code). |
group_name | A group name. |
key | A key. |
GKeyFile * Glib::KeyFile::gobj | ( | ) |
Provides access to the underlying C instance.
GKeyFile * Glib::KeyFile::gobj_copy | ( | ) | const |
Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
bool Glib::KeyFile::has_group | ( | const Glib::ustring & | group_name | ) | const |
Looks whether the key file has the group group_name.
group_name | A group name. |
true
if group_name is a part of key_file, false
otherwise. 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.
Glib::KeyFileError |
group_name | A group name. |
key | A key name. |
true
if key is a part of group_name, false
otherwise. bool Glib::KeyFile::load_from_data | ( | const Glib::ustring & | data, |
Flags | flags = Flags::NONE |
||
) |
Loads a KeyFile from memory.
data | The data to use as a KeyFile |
flags | Bitwise combination of the flags to use for the KeyFile |
Glib::KeyFileError |
bool Glib::KeyFile::load_from_data_dirs | ( | const std::string & | file, |
std::string & | full_path, | ||
Flags | flags = Flags::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.
file | The file to search for | |
[out] | 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 |
Glib::KeyFileError | |
Glib::FileError |
bool Glib::KeyFile::load_from_dirs | ( | const std::string & | file, |
const std::vector< std::string > & | search_dirs, | ||
std::string & | full_path, | ||
Flags | flags = Flags::NONE |
||
) |
This function looks for a key file named file in the paths specified in search_dirs, loads the file into key_file and returns the file's full path in full_path.
If the file could not be found in any of the search_dirs, Glib::KeyFileError::NOT_FOUND is returned. If the file is found but the OS returns an error when opening or reading the file, a Glib::FileError is returned. If there is a problem parsing the file, a Glib::KeyFileError is returned.
file | A relative path to a filename to open and parse. |
search_dirs | nullptr -terminated array of directories to search. |
full_path | Return location for a string containing the full path of the file, or nullptr . |
flags | Flags from Glib::KeyFile::Flags. |
true
if a key file could be loaded, false
otherwise.Glib::KeyFileError | |
Glib::FileError |
bool Glib::KeyFile::load_from_file | ( | const std::string & | file, |
Flags | flags = Flags::NONE |
||
) |
Loads a key file into an empty KeyFile instance.
If the file could not be loaded then a FileError or KeyFileError exception is thrown.
Glib::FileError | |
Glib::KeyFileError |
file | The path of a filename to load, in the GLib filename encoding. |
flags | Flags from Glib::KeyFile::Flags. |
true
if a key file could be loaded, false
otherwise. void Glib::KeyFile::reference | ( | ) | const |
Increment the reference count for this object.
You should never need to do this manually - use the object via a RefPtr instead.
void Glib::KeyFile::remove_comment | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key | ||
) |
Removes a comment above key from group_name.
If key is nullptr
then comment will be removed above group_name. If both key and group_name are nullptr
, then comment will be removed above the first group in the file.
Glib::KeyFileError |
group_name | A group name, or nullptr . |
key | A key. |
void Glib::KeyFile::remove_group | ( | const Glib::ustring & | group_name | ) |
Removes the specified group, group_name, from the key file.
Glib::KeyFileError |
group_name | A group name. |
void Glib::KeyFile::remove_key | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key | ||
) |
Removes key in group_name from the key file.
Glib::KeyFileError |
group_name | A group name. |
key | A key name to remove. |
bool Glib::KeyFile::save_to_file | ( | const std::string & | filename | ) |
Writes the contents of key_file to filename using g_file_set_contents().
If you need stricter guarantees about durability of the written file than are provided by g_file_set_contents(), use g_file_set_contents_full() with the return value of g_key_file_to_data().
This function can fail for any of the reasons that g_file_set_contents() may fail.
filename | The name of the file to write to. |
true
if successful, else false
with error set.Glib::FileError |
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.
group_name | A group name. |
key | A key. |
value | true or false . |
void Glib::KeyFile::set_boolean_list | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key, | ||
const std::vector< 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.
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_comment | ( | const Glib::ustring & | comment | ) |
Places comment at the start of the file, before the first group.
comment | The Comment |
Glib::KeyFileError |
void Glib::KeyFile::set_comment | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | comment | ||
) |
Places comment above group_name.
group_name | The Group the comment should be above |
comment | The comment |
Glib::KeyFileError |
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.
If key is nullptr
then comment will be written above group_name.
If both key and group_name are nullptr
, then comment will be written above the first group in the file.
Glib::KeyFileError |
group_name | A group name, or nullptr . |
key | A key. |
comment | A comment. |
void Glib::KeyFile::set_double | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key, | ||
double | value | ||
) |
Associates a new double value with key under group_name.
If key cannot be found then it is created.
group_name | A group name. |
key | A key. |
value | A double value. |
void Glib::KeyFile::set_double | ( | const Glib::ustring & | key, |
double | value | ||
) |
Associates a new double value with key under the start group.
If key cannot be found then it is created.
key | A key. |
value | An double value. |
void Glib::KeyFile::set_double_list | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key, | ||
const std::vector< double > & | list | ||
) |
Sets a list of doubles for the key under group_name.
If either the key or group_name cannot be found they are created.
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_int64 | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key, | ||
gint64 | value | ||
) |
Associates a new integer value with key under group_name.
If key cannot be found then it is created.
group_name | A group name. |
key | A key. |
value | An integer value. |
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.
group_name | A group name. |
key | A key. |
value | An integer value. |
void Glib::KeyFile::set_integer_list | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key, | ||
const std::vector< 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.
group_name | The name of a group |
key | The name of a key |
list | A list holding object of type int |
Sets the character which is used to separate values in lists.
Typically ';' or ',' are used as separators. The default list separator is ';'.
separator | The separator. |
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.
group_name | A group name. |
key | A key. |
locale | A locale identifier. |
string | A string. |
void Glib::KeyFile::set_locale_string_list | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key, | ||
const Glib::ustring & | locale, | ||
const std::vector< 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.
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_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. Unlike g_key_file_set_value(), this function handles characters that need escaping, such as newlines.
group_name | A group name. |
key | A key. |
string | A string. |
void Glib::KeyFile::set_string_list | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key, | ||
const std::vector< 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.
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_uint64 | ( | const Glib::ustring & | group_name, |
const Glib::ustring & | key, | ||
guint64 | value | ||
) |
Associates a new integer value with key under group_name.
If key cannot be found then it is created.
group_name | A group name. |
key | A key. |
value | An integer value. |
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. To set an UTF-8 string which may contain characters that need escaping (such as newlines or spaces), use g_key_file_set_string().
group_name | A group name. |
key | A key. |
value | A string. |
Glib::ustring Glib::KeyFile::to_data | ( | ) |
Outputs the KeyFile as a string.
Glib::KeyFileError |
void Glib::KeyFile::unreference | ( | ) | const |
Decrement the reference count for this object.
You should never need to do this manually - use the object via a RefPtr instead.
|
related |
A Glib::wrap() method for this object.
object | The C instance. |
take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref. |