#include <cdbreader.h>
Public Member Functions | |
| CDBReader (const QString &dbpath, QObject *parent=0) | |
| Constructs a new CDBReader reading from cdb database at dbpath. | |
| virtual | ~CDBReader () |
| Destroys the object automatically closing the database and file. | |
| void | close () |
| Closes the reader and the underlying file on the filesystem. | |
| void | reopen () |
| Reopens the reader for reading. | |
| QVariantList | valuesForKey (const QString &key) const |
| Returns all values associated with the given key from the database. | |
| QVariant | valueForKey (const QString &key) const |
| Returns a value for the given key. | |
| bool | isReadable () |
| Returns the current state of the reader. | |
| int | fileDescriptor () const |
| Returns the file descriptor used by the reader. | |
Private Attributes | |
| QString | path |
| Path pointing to the database. | |
| void * | cdb |
| Cdb library object used for reading. | |
| int | fd |
| A file descriptor to the database. | |
This class is not a part of the public API. The reader operates on string-qvariant pairs: can read a qvariant value for a string key or a list of qvariant values for a string key. The reader automatically closes the underlying filesystem resource on destruction but can be also closed manually.
Reading from a closed reader will return empty strings.
| CDBReader::CDBReader | ( | const QString & | dbpath, | |
| QObject * | parent = 0 | |||
| ) | [explicit] |
Constructs a new CDBReader reading from cdb database at dbpath.
| dbpath | Path to the database. |
| CDBReader::~CDBReader | ( | ) | [virtual] |
Destroys the object automatically closing the database and file.
| void CDBReader::close | ( | ) |
Closes the reader and the underlying file on the filesystem.
| void CDBReader::reopen | ( | ) |
Reopens the reader for reading.
It will first close the current reader if it's open.
| QVariantList CDBReader::valuesForKey | ( | const QString & | key | ) | const |
Returns all values associated with the given key from the database.
| key | The key name in the database. |
| QVariant CDBReader::valueForKey | ( | const QString & | key | ) | const |
Returns a value for the given key.
First value is returned if there are many values for one key.
| key | The key name in the database. |
| bool CDBReader::isReadable | ( | ) |
Returns the current state of the reader.
Reader is not readable if it was created with a path that doesn't exist or if it was closed.
| int CDBReader::fileDescriptor | ( | ) | const |
Returns the file descriptor used by the reader.
Returns 0 when the reader is closed.
QString CDBReader::path [private] |
Path pointing to the database.
void* CDBReader::cdb [private] |
Cdb library object used for reading.
int CDBReader::fd [private] |
A file descriptor to the database.
1.5.6