C++ API of Depot, the basic API of QDBM. More...
Public Member Functions | |
Depot (const char *name, int omode=Depot::OREADER, int bnum=-1) throw (Depot_error) | |
Get the database handle. | |
virtual | ~Depot () throw () |
Release the resources. | |
virtual void | close () throw (Depot_error) |
Close the database handle. | |
virtual bool | put (const char *kbuf, int ksiz, const char *vbuf, int vsiz, int dmode=Depot::DOVER) throw (Depot_error) |
Store a record. | |
virtual bool | out (const char *kbuf, int ksiz) throw (Depot_error) |
Delete a record. | |
virtual char * | get (const char *kbuf, int ksiz, int start=0, int max=-1, int *sp=0) throw (Depot_error) |
Retrieve a record. | |
virtual int | getwb (const char *kbuf, int ksiz, int start, int max, char *vbuf) throw (Depot_error) |
Retrieve a record and write the value into a buffer. | |
virtual int | vsiz (const char *kbuf, int ksiz) throw (Depot_error) |
Get the size of the value of a record. | |
virtual void | iterinit () throw (Depot_error) |
Initialize the iterator of the database handle. | |
virtual char * | iternext (int *sp=0) throw (Depot_error) |
Get the next key of the iterator. | |
virtual void | setalign (int align) throw (Depot_error) |
Set alignment of the database handle. | |
virtual void | setfbpsiz (int size) throw (Depot_error) |
Set the size of the free block pool. | |
virtual void | sync () throw (Depot_error) |
Synchronize updating contents with the file and the device. | |
virtual void | optimize (int bnum=-1) throw (Depot_error) |
Optimize the database. | |
virtual char * | name () throw (Depot_error) |
Get the name of the database. | |
virtual int | fsiz () throw (Depot_error) |
Get the size of the database file. | |
virtual int | bnum () throw (Depot_error) |
Get the number of the elements of the bucket array. | |
virtual int | busenum () throw (Depot_error) |
Get the number of the used elements of the bucket array. | |
virtual int | rnum () throw (Depot_error) |
Get the number of the records stored in the database. | |
virtual bool | writable () throw (Depot_error) |
Check whether the database handle is a writer or not. | |
virtual bool | fatalerror () throw (Depot_error) |
Check whether the database has a fatal error or not. | |
virtual int | inode () throw (Depot_error) |
Get the inode number of the database file. | |
virtual time_t | mtime () throw (Depot_error) |
Get the last modified time of the database. | |
virtual int | fdesc () throw (Depot_error) |
Get the file descriptor of the database file. | |
virtual void | storerec (const Datum &key, const Datum &val, bool replace=true) throw (Depot_error) |
Store a record. | |
virtual void | deleterec (const Datum &key) throw (Depot_error) |
Delete a record. | |
virtual Datum | fetchrec (const Datum &key) throw (Depot_error) |
Fetch a record. | |
virtual Datum | firstkey () throw (Depot_error) |
Get the first key. | |
virtual Datum | nextkey () throw (Depot_error) |
Get the next key. | |
virtual bool | error () throw (Depot_error) |
Check whether a fatal error occured or not. | |
Static Public Member Functions | |
static const char * | version () throw () |
Get the version information. | |
static void | remove (const char *name) throw (Depot_error) |
Remove a database file. | |
static char * | snaffle (const char *name, const char *kbuf, int ksiz, int *sp) throw (Depot_error) |
Retrieve a record directly from a database file. | |
Public Attributes | |
bool | silent |
whether to repress frequent exceptions | |
Static Public Attributes | |
static const int | ENOERR |
error code: no error | |
static const int | EFATAL |
error code: with fatal error | |
static const int | EMODE |
error code: invalid mode | |
static const int | EBROKEN |
error code: broken database file | |
static const int | EKEEP |
error code: existing record | |
static const int | ENOITEM |
error code: no item found | |
static const int | EALLOC |
error code: memory allocation error | |
static const int | EMAP |
error code: memory mapping error | |
static const int | EOPEN |
error code: open error | |
static const int | ECLOSE |
error code: close error | |
static const int | ETRUNC |
error code: trunc error | |
static const int | ESYNC |
error code: sync error | |
static const int | ESTAT |
error code: stat error | |
static const int | ESEEK |
error code: seek error | |
static const int | EREAD |
error code: read error | |
static const int | EWRITE |
error code: write error | |
static const int | ELOCK |
error code: lock error | |
static const int | EUNLINK |
error code: unlink error | |
static const int | EMKDIR |
error code: mkdir error | |
static const int | ERMDIR |
error code: rmdir error | |
static const int | EMISC |
error code: miscellaneous error | |
static const int | OREADER |
open mode: open as a reader | |
static const int | OWRITER |
open mode: open as a writer | |
static const int | OCREAT |
open mode: writer creating | |
static const int | OTRUNC |
open mode: writer truncating | |
static const int | ONOLCK |
open mode: open without locking | |
static const int | OLCKNB |
open mode: lock without blocking | |
static const int | OSPARSE |
open mode: create as a sparse file | |
static const int | DOVER |
write mode: overwrite the existing value | |
static const int | DKEEP |
write mode: keep the existing value | |
static const int | DCAT |
write mode: concatenate values |
C++ API of Depot, the basic API of QDBM.
qdbm::Depot::Depot | ( | const char * | name, | |
int | omode = Depot::OREADER , |
|||
int | bnum = -1 | |||
) | throw (Depot_error) |
Get the database handle.
name | the name of a database file. | |
omode | the connection mode: `DepotOWRITER' as a writer, `DepotOREADER' as a reader. If the mode is `DepotOWRITER', the following may be added by bitwise or: `DepotOCREAT', which means it creates a new database if not exist, `DepotOTRUNC', which means it creates a new database regardless if one exists. Both of `DepotOREADER' and `DepotOWRITER' can be added to by bitwise or: `DepotONOLCK', which means it opens a database file without file locking, or `DepotOLCKNB', which means locking is performed without blocking. `DepotOCREAT' can be added to by bitwise or: `DepotOSPARSE', which means it creates a database file as a sparse file. | |
bnum | the number of elements of the bucket array. If it is not more than 0, the default value is specified. The size of a bucket array is determined on creating, and can not be changed except for by optimization of the database. Suggested size of a bucket array is about from 0.5 to 4 times of the number of all records to store. |
Depot_error | if an error occurs. |
virtual qdbm::Depot::~Depot | ( | ) | throw () [virtual] |
Release the resources.
virtual int qdbm::Depot::bnum | ( | ) | throw (Depot_error) [virtual] |
Get the number of the elements of the bucket array.
Depot_error | if an error occurs. |
virtual int qdbm::Depot::busenum | ( | ) | throw (Depot_error) [virtual] |
Get the number of the used elements of the bucket array.
Depot_error | if an error occurs. |
virtual void qdbm::Depot::close | ( | ) | throw (Depot_error) [virtual] |
Close the database handle.
Depot_error | if an error occurs. |
Implements qdbm::ADBM.
virtual void qdbm::Depot::deleterec | ( | const Datum & | key | ) | throw (Depot_error) [virtual] |
Delete a record.
key | reference to a key object. |
Depot_error | if an error occurs or no record corresponds. |
Implements qdbm::ADBM.
virtual bool qdbm::Depot::error | ( | ) | throw (Depot_error) [virtual] |
Check whether a fatal error occured or not.
Depot_error | if an error occurs. |
Implements qdbm::ADBM.
virtual bool qdbm::Depot::fatalerror | ( | ) | throw (Depot_error) [virtual] |
Check whether the database has a fatal error or not.
Depot_error | if an error occurs. |
virtual int qdbm::Depot::fdesc | ( | ) | throw (Depot_error) [virtual] |
Get the file descriptor of the database file.
Depot_error | if an error occurs. |
virtual Datum qdbm::Depot::fetchrec | ( | const Datum & | key | ) | throw (Depot_error) [virtual] |
Fetch a record.
key | reference to a key object. |
Depot_error | if an error occurs or no record corresponds. |
Implements qdbm::ADBM.
virtual Datum qdbm::Depot::firstkey | ( | ) | throw (Depot_error) [virtual] |
Get the first key.
Depot_error | if an error occurs or no record corresponds. |
Implements qdbm::ADBM.
virtual int qdbm::Depot::fsiz | ( | ) | throw (Depot_error) [virtual] |
Get the size of the database file.
Depot_error | if an error occurs. |
virtual char* qdbm::Depot::get | ( | const char * | kbuf, | |
int | ksiz, | |||
int | start = 0 , |
|||
int | max = -1 , |
|||
int * | sp = 0 | |||
) | throw (Depot_error) [virtual] |
Retrieve a record.
kbuf | the pointer to the region of a key. | |
ksiz | the size of the region of the key. If it is negative, the size is assigned with `stdstrlen(kbuf)'. | |
start | the offset address of the beginning of the region of the value to be read. | |
max | the max size to read with. If it is negative, the size is unlimited. | |
sp | the pointer to a variable to which the size of the region of the return value is assigned. If it is 0, it is not used. |
Depot_error | if an error occurs, no record corresponds, or the size of the value of the corresponding record is less than `start'. |
virtual int qdbm::Depot::getwb | ( | const char * | kbuf, | |
int | ksiz, | |||
int | start, | |||
int | max, | |||
char * | vbuf | |||
) | throw (Depot_error) [virtual] |
Retrieve a record and write the value into a buffer.
kbuf | the pointer to the region of a key. | |
ksiz | the size of the region of the key. If it is negative, the size is assigned with `stdstrlen(kbuf)'. | |
start | the offset address of the beginning of the region of the value to be read. | |
max | the max size to be read. It shuld be equal to or less than the size of the writing buffer. | |
vbuf | the pointer to a buffer into which the value of the corresponding record is written. |
Depot_error | if an error occurs, no record corresponds, or the size of the value of the corresponding record is less than `start'. |
virtual int qdbm::Depot::inode | ( | ) | throw (Depot_error) [virtual] |
Get the inode number of the database file.
Depot_error | if an error occurs. |
virtual void qdbm::Depot::iterinit | ( | ) | throw (Depot_error) [virtual] |
Initialize the iterator of the database handle.
Depot_error | if an error occurs. |
virtual char* qdbm::Depot::iternext | ( | int * | sp = 0 |
) | throw (Depot_error) [virtual] |
Get the next key of the iterator.
sp | the pointer to a variable to which the size of the region of the return value is assigned. If it is 0, it is not used. |
Depot_error | if an error occurs or no record is to be get out of the iterator. |
virtual time_t qdbm::Depot::mtime | ( | ) | throw (Depot_error) [virtual] |
Get the last modified time of the database.
Depot_error | if an error occurs. |
virtual char* qdbm::Depot::name | ( | ) | throw (Depot_error) [virtual] |
Get the name of the database.
Depot_error | if an error occurs. |
virtual Datum qdbm::Depot::nextkey | ( | ) | throw (Depot_error) [virtual] |
Get the next key.
Depot_error | if an error occurs or no record corresponds. |
Implements qdbm::ADBM.
virtual void qdbm::Depot::optimize | ( | int | bnum = -1 |
) | throw (Depot_error) [virtual] |
Optimize the database.
bnum | the number of the elements of the bucket array. If it is not more than 0, the default value is specified. |
Depot_error | if an error occurs. |
virtual bool qdbm::Depot::out | ( | const char * | kbuf, | |
int | ksiz | |||
) | throw (Depot_error) [virtual] |
Delete a record.
kbuf | the pointer to the region of a key. | |
ksiz | the size of the region of the key. If it is negative, the size is assigned with `stdstrlen(kbuf)'. |
Depot_error | if an error occurs or no record corresponds. |
virtual bool qdbm::Depot::put | ( | const char * | kbuf, | |
int | ksiz, | |||
const char * | vbuf, | |||
int | vsiz, | |||
int | dmode = Depot::DOVER | |||
) | throw (Depot_error) [virtual] |
Store a record.
kbuf | the pointer to the region of a key. | |
ksiz | the size of the region of the key. If it is negative, the size is assigned with `stdstrlen(kbuf)'. | |
vbuf | the pointer to the region of a value. | |
vsiz | the size of the region of the value. If it is negative, the size is assigned with `stdstrlen(vbuf)'. | |
dmode | behavior when the key overlaps, by the following values: `DepotDOVER', which means the specified value overwrites the existing one, `DepotDKEEP', which means the existing value is kept, `DepotDCAT', which means the specified value is concatenated at the end of the existing value. |
Depot_error | if an error occurs or replace is cancelled. |
static void qdbm::Depot::remove | ( | const char * | name | ) | throw (Depot_error) [static] |
Remove a database file.
name | the name of a database file. |
Depot_error | if an error occurs. |
virtual int qdbm::Depot::rnum | ( | ) | throw (Depot_error) [virtual] |
Get the number of the records stored in the database.
Depot_error | if an error occurs. |
virtual void qdbm::Depot::setalign | ( | int | align | ) | throw (Depot_error) [virtual] |
Set alignment of the database handle.
align | the basic size of alignment. |
Depot_error | if an error occurs. |
virtual void qdbm::Depot::setfbpsiz | ( | int | size | ) | throw (Depot_error) [virtual] |
Set the size of the free block pool.
size | the size of the free block pool of a database. |
Depot_error | if an error occurs. |
static char* qdbm::Depot::snaffle | ( | const char * | name, | |
const char * | kbuf, | |||
int | ksiz, | |||
int * | sp | |||
) | throw (Depot_error) [static] |
Retrieve a record directly from a database file.
name | the name of a database file. | |
kbuf | the pointer to the region of a key. | |
ksiz | the size of the region of the key. If it is negative, the size is assigned with `stdstrlen(kbuf)'. | |
sp | the pointer to a variable to which the size of the region of the return value is assigned. If it is 0, it is not used. |
Depot_error | if an error occurs or no record corresponds. |
virtual void qdbm::Depot::storerec | ( | const Datum & | key, | |
const Datum & | val, | |||
bool | replace = true | |||
) | throw (Depot_error) [virtual] |
Store a record.
key | reference to a key object. | |
val | reference to a value object. | |
replace | whether the existing value is to be overwritten or not. |
Depot_error | if an error occurs or replace is cancelled. |
Implements qdbm::ADBM.
virtual void qdbm::Depot::sync | ( | ) | throw (Depot_error) [virtual] |
Synchronize updating contents with the file and the device.
Depot_error | if an error occurs. |
static const char* qdbm::Depot::version | ( | ) | throw () [static] |
Get the version information.
virtual int qdbm::Depot::vsiz | ( | const char * | kbuf, | |
int | ksiz | |||
) | throw (Depot_error) [virtual] |
Get the size of the value of a record.
kbuf | the pointer to the region of a key. | |
ksiz | the size of the region of the key. If it is negative, the size is assigned with `stdstrlen(kbuf)'. |
Depot_error | if an error occurs or no record corresponds. |
virtual bool qdbm::Depot::writable | ( | ) | throw (Depot_error) [virtual] |
Check whether the database handle is a writer or not.
Depot_error | if an error occurs. |