KGDbm Class Reference

[kdbm Index] [kdbm Hierarchy]


Abstract base class for the KDBM package. More...

#include <kdbm.h>

Public Members

Protected Members


Detailed Description

The KGDbm class is an internal class for implementing KDbm and KIntDbm. For an introductory guide, see KDbm documentation.


enum KDbmOpenMode ( read, readWrite )

Used for the open method.

virtual bool create(char* file)

Create a new database. If a database with the same name already exists, then it is replaced by the new database. The created database is open for reading and writing in exclusive mode.

Parameters:
file is the name of the file in which the database is stored.
Returns:
true if successful, false if the database cannot be created.
See Also:
open

virtual bool open(char* file, enum KDbmOpenMode mode = read)

Open an existing database or, if a database with the given name does not exist and setForceMode(true) has been previously invoked, create a new one.

Many readers can access the database at the same time. If a database is open for writing, the access is exclusive.

Parameters:
file is the name of the database file.
mode can be either KGDbm::read (default) or KGDbm::readWrite. KGDbm::readWrite implies exclusive database access.
Returns:
true if successful, false if the database cannot be open.
See Also:
create

virtual void close()

Close the last opened database.

virtual int errno()

If there is a file system error during a database operation, returns the error code.

virtual int get_gdbm_errno()

If there is a gdbm error during a database operation, returns the error code. (see gdbm.h for error codes).

virtual bool found()

Return true if the last searched item has been found. Should be checked after using [] or take to retrieve database items.

virtual void reorganize()

Reorganize the current database.

If you have had a lot of deletions and would like to shrink the space used by the `gdbm' file, this function will reorganize the database. `gdbm' will not shorten the length of a `gdbm' file (deleted file space will be reused) except by using this reorganization. `reorganize' should be used very seldom.

virtual void sync()

Allows the programmer to make sure the disk version of the database has been completely updated with all changes to the current time.

If the fast mode has been set, the database engine does not wait for writes to the disk to complete before continuing. This allows faster writing of databases at the risk of having a corrupted database if the application terminates in an abnormal fashion. `sync' is usually called after a complete set of changes have been made to the database and before some long waiting time. Note that the close method automatically invokes sync.

virtual bool bufferIsEnabled()

Return true if data buffering is enabled.

See Memory Management

virtual void enableBuffer(int _initSize = 100)

Enable buffering for retrieved items. Since buffering is enabled by default, this function is meaningful only after a call to disableBuffer.

See Memory Management

virtual void disableBuffer()

Disable buffering for retrieved items: users must explicitly release pointers to retrieved database items when no more needed.

See Memory Management

virtual int resizeBuffer(int _newSize)

If _newSize >= 0, resizes the current buffer. resizeBuffer(0) will just return the current buffer size, leaving it unchanged.

Since the buffer grows to fit retrieved items, this method is useful to reduce the size of the buffer periodically.

See Memory Management

bool isOpen()

Return true if this object is associated to an open database. Can be checked after a create or open operation to test if the database is really opened.

void setForceFlag(bool flag)

If this property is set to true before an open operation is attempted, then the database is created if it does not exist. Otherwise (default) open will fail.

int getForceFlag()

See setForceFlag.

void setBlockSize(int size)

Used during the database creation to determine the size of various constructs. It is the size of a single transfer from disk to memory. This parameter is ignored if the file has been previously initialized. The minimum size is 512. If the value is less than 512, the file system blocksize is used, otherwise this value is used.

Default is 1024.

int getBlockSize()

See setBlockSize.

void setAccessMode(int mode)

The permission to use if a new database is created. It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask).

See also man pages for chmod(2) and open(2).

Should be set before an operation in which a new database is created.

Default is S_IRUSR | S_IWUSR, i.e. user has read and write permission.

int getAccessMode()

See setAccessMode.

void setFastMode(bool flag)

If this property is set to true then the database will be written without any disk file synchronization. This allows faster writes, but may produce an inconsistent database in the event of abnormal termination of the writer. Can be set at any time.

Default is false.

bool getFastMode()

See setFastMode.

void setCacheSize(int size)

Set the size of the internal bucket cache. This option may only be set once after a database has been open and should be set prior to accessing it in any way.

Default is 100.

int getCacheSize()

See setCacheSize.


  • Author: Pietro Iglio (iglio@kde.org)
  • Documentation generated by iglio@localhost on Thu Oct 15 19:05:38 GMT 1998
Kdoc