CDBReader Class Reference

A wrapper class to read data from a tiny-cdb database. More...

#include <cdbreader.h>

List of all members.

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.


Detailed Description

A wrapper class to read data from a tiny-cdb 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.


Constructor & Destructor Documentation

CDBReader::CDBReader ( const QString &  dbpath,
QObject *  parent = 0 
) [explicit]

Constructs a new CDBReader reading from cdb database at dbpath.

Parameters:
dbpath Path to the database.

CDBReader::~CDBReader (  )  [virtual]

Destroys the object automatically closing the database and file.


Member Function Documentation

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.

Parameters:
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.

Parameters:
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.


Member Data Documentation

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.


The documentation for this class was generated from the following files:

Generated on Sun Apr 21 16:11:51 2013 for libcontextsubscriber by  doxygen 1.5.6