Home · Modules · Classes · Namespaces · Functions

QxtBdbHash Class Reference
[QxtBerkeley module]

The QxtBdbHash class is a template class that provides key/value access to a berkeley db file. More...

    #include <QxtBdbHash>

Public Functions


Detailed Description

The QxtBdbHash class is a template class that provides key/value access to a berkeley db file.

Both value and key must be registered with the qt meta system. You may not touch the file while a QxtBdbHash instance is running on it.

examples usage:

    QxtBdbHash<qreal,QStringList> db("test.db");
    db.insert(344.4,QStringList<<"HI"<<":)");
    qDebug()<<db[344.4];

There is an extensive example in /examples/berkeley/adressbook.

All functions of this class are thread safe. Calling open() multiple times is undefined. An iterator may only be used from one thread at once, but you can have multiple iterators.

TODO: {implicitshared}

See also QxtBdbHashIterator.


Member Function Documentation

QxtBdbHash::QxtBdbHash ()

Constructs an invalid QxtBdbHash

QxtBdbHash::QxtBdbHash ( QString file )

Constructs a QxtBdbHash, and opens the file specified as its database.

QxtBdbHashIterator<KEY, VAL> QxtBdbHash::begin ()

Returns an iterator to the first key,value pair.

See also QxtBdbHashIterator.

void QxtBdbHash::clear ()

Erase all records. This does not delete the underlying file.

bool QxtBdbHash::contains ( const KEY & key ) const

Returns true if there is a record for the specified key.

QxtBdbHashIterator<KEY, VAL> QxtBdbHash::end ()

Return an iterator to the last key,value pair

See also QxtBdbHashIterator.

QxtBdbHashIterator<KEY, VAL> QxtBdbHash::find ( const KEY & key )

Returns an iterator to the position of the pair identified by key

See also QxtBdbHashIterator.

bool QxtBdbHash::flush ()

Flushes the underlying DB file. All changes are synced to disk.

bool QxtBdbHash::insert ( KEY key, VAL value )

Inserts a record with the specified key / value combination. Replaces any record with the same key. Note: When working with iterators, keep in mind that inserting pairs, works reverse to the iteration.

bool QxtBdbHash::open ( QString file )

Opens the specified file.

Returns true on success and false on failure. Note: A sanity check is performed before opening the file.

bool QxtBdbHash::remove ( const KEY & key )

Removes all records with the specified key. Returns true on success and false on failure.

const VAL QxtBdbHash::value ( const KEY & key ) const

Returns the value associated with the specified key, or a default contructed value, if no such key exists.

const VAL QxtBdbHash::operator[] ( const KEY & key ) const

Same as value()


Copyright © 2007-2011 Qxt Foundation
Qxt 0.6.2