TelepathyQt4: Tp::KeyFile Class Reference

| Home · All Classes · All Namespaces · Modules · Functions · Files

# Tp::KeyFile Class Reference

The KeyFile class provides an easy way to read key-pair files such as INI style files and .desktop files. More...

`#include <TelepathyQt4/KeyFile>`

List of all members.

## Public Types

- enum Status {
  None, NoError, NotFoundError, AccessError,
  FormatError
  }

## Public Member Functions

- KeyFile ()
- KeyFile (const QString &fileName)
- ~KeyFile ()
- void setFileName (const QString &fileName)
- QString fileName () const
- Status status () const
- void setGroup (const QString &group)
- QString group () const
- QStringList allGroups () const
- QStringList allKeys () const
- QStringList keys () const
- bool contains (const QString &key) const
- QString rawValue (const QString &key) const
- QString value (const QString &key) const
- QStringList valueAsStringList (const QString &key) const

## Detailed Description

The KeyFile class provides an easy way to read key-pair files such as INI style files and .desktop files.

It follows the rules regarding string escaping as defined in http://standards.freedesktop.org/desktop-entry-spec/latest/index.html

## Member Enumeration Documentation

enum Tp::KeyFile::Status

Enumerator:

  None |
  NoError |
  NotFoundError |
  AccessError |
  FormatError |

## Constructor & Destructor Documentation

Tp::KeyFile::KeyFile | ( |  | ) |

Create a KeyFile object used to read (key-pair) compliant files.

The status will be KeyFile::None

See also:
  setFileName()

Tp::KeyFile::KeyFile | ( | const QString & | fileName | ) |

Create a KeyFile object used to read (key-pair) compliant files.

Parameters:

  | fileName | Name of the file to be read.

Tp::KeyFile::~KeyFile | ( |  | ) |

Class destructor.

## Member Function Documentation

void Tp::KeyFile::setFileName | ( | const QString & | fileName | ) |

Set the name of the file to be read.

Parameters:

  | fileName | Name of the file to be read.

QString Tp::KeyFile::fileName | ( |  | ) | const

Return the name of the file associated with this object.

Returns:
  Name of the file associated with this object.

KeyFile::Status Tp::KeyFile::status | ( |  | ) | const

Return a status code indicating the first error that was met by KeyFile, or KeyFile::NoError if no error occurred.

Make sure to use this method if you set the filename to be read using setFileName().

Returns:
  Status code.

See also:
  setFileName()

void Tp::KeyFile::setGroup | ( | const QString & | group | ) |

Set the current group to be used while reading keys.

Query functions such as keys(), contains() and value() are based on this group.

By default a empty group is used as the group for global keys and is used as the default group if none is set.

Parameters:

  | group | Name of the group to be used.

See also:
  group()

QString Tp::KeyFile::group | ( |  | ) | const

Return the current group.

Returns:
  Name of the current group.

See also:
  setGroup()

QStringList Tp::KeyFile::allGroups | ( |  | ) | const

Return all groups in the desktop file.

Global keys will be added to a empty group.

Returns:
  List of all groups in the desktop file.

QStringList Tp::KeyFile::allKeys | ( |  | ) | const

Return all keys described in the desktop file.

Returns:
  List of all keys in the desktop file.

QStringList Tp::KeyFile::keys | ( |  | ) | const

Return a list of keys in the current group.

Returns:
  List of all keys in the current group.

See also:
  group(), setGroup()

bool Tp::KeyFile::contains | ( | const QString & | key | ) | const

Check if the current group contains a key named key.

Returns:
  true if key exists, false otherwise.

See also:
  group(), setGroup()

QString Tp::KeyFile::rawValue | ( | const QString & | key | ) | const

Get the raw value for the key in the current group named key.

The raw value is the value as is in the key file.

Returns:
  Value of key, empty string if not found.

See also:
  group(), setGroup()

QString Tp::KeyFile::value | ( | const QString & | key | ) | const

Get the value for the key in the current group named key.

Escape sequences in the value are interpreted as defined in: http://standards.freedesktop.org/desktop-entry-spec/latest/

Returns:
  Value of key, empty string if not found or an error occurred.

See also:
  group(), setGroup()

QStringList Tp::KeyFile::valueAsStringList | ( | const QString & | key | ) | const

Get the value for the key in the current group named key as a list.

Return a list containing all strings on this key separated by ';'. Escape sequences in the value are interpreted as defined in: http://standards.freedesktop.org/desktop-entry-spec/latest/

Returns:
  Value of key as a list, empty string list if not found or an error occurred.

See also:
  group(), setGroup()