C++ API of Curia, the extended API of QDBM. More...
Public Member Functions | |
Curia (const char *name, int omode=Curia::OREADER, int bnum=-1, int dnum=-1) throw (Curia_error) | |
Get the database handle. | |
virtual | ~Curia () throw () |
Release the resources. | |
virtual void | close () throw (Curia_error) |
Close the database handle. | |
virtual bool | put (const char *kbuf, int ksiz, const char *vbuf, int vsiz, int dmode=Curia::DOVER) throw (Curia_error) |
Store a record. | |
virtual bool | out (const char *kbuf, int ksiz) throw (Curia_error) |
Delete a record. | |
virtual char * | get (const char *kbuf, int ksiz, int start=0, int max=-1, int *sp=0) throw (Curia_error) |
Retrieve a record. | |
virtual int | getwb (const char *kbuf, int ksiz, int start, int max, char *vbuf) throw (Curia_error) |
Retrieve a record and write the value into a buffer. | |
virtual int | vsiz (const char *kbuf, int ksiz) throw (Curia_error) |
Get the size of the value of a record. | |
virtual void | iterinit () throw (Curia_error) |
Initialize the iterator of the database handle. | |
virtual char * | iternext (int *sp=0) throw (Curia_error) |
Get the next key of the iterator. | |
virtual void | setalign (int align) throw (Curia_error) |
Set alignment of the database handle. | |
virtual void | setfbpsiz (int size) throw (Curia_error) |
Set the size of the free block pool. | |
virtual void | sync () throw (Curia_error) |
Synchronize updating contents with the files and the devices. | |
virtual void | optimize (int bnum=-1) throw (Curia_error) |
Optimize the database. | |
virtual char * | name () throw (Curia_error) |
Get the name of the database. | |
virtual int | fsiz () throw (Curia_error) |
Get the total size of database files. | |
virtual double | fsizd () throw (Curia_error) |
Get the total size of database files as double-precision floating-point number. | |
virtual int | bnum () throw (Curia_error) |
Get the total number of the elements of each bucket array. | |
virtual int | busenum () throw (Curia_error) |
Get the total number of the used elements of each bucket array. | |
virtual int | rnum () throw (Curia_error) |
Get the number of the records stored in the database. | |
virtual bool | writable () throw (Curia_error) |
Check whether the database handle is a writer or not. | |
virtual bool | fatalerror () throw (Curia_error) |
Check whether the database has a fatal error or not. | |
virtual int | inode () throw (Curia_error) |
Get the inode number of the database directory. | |
virtual time_t | mtime () throw (Curia_error) |
Get the last modified time of the database. | |
virtual bool | putlob (const char *kbuf, int ksiz, const char *vbuf, int vsiz, int dmode=Curia::DOVER) throw (Curia_error) |
Store a large object. | |
virtual bool | outlob (const char *kbuf, int ksiz) throw (Curia_error) |
Delete a large object. | |
virtual char * | getlob (const char *kbuf, int ksiz, int start=0, int max=-1, int *sp=0) throw (Curia_error) |
Retrieve a large object. | |
virtual int | getlobfd (const char *kbuf, int ksiz) |
Get the file descriptor of a large object. | |
virtual int | vsizlob (const char *kbuf, int ksiz) throw (Curia_error) |
Get the size of the value of a large object. | |
virtual int | rnumlob () throw (Curia_error) |
Get the number of the large objects stored in the database. | |
virtual void | storerec (const Datum &key, const Datum &val, bool replace=true) throw (Curia_error) |
Store a record. | |
virtual void | deleterec (const Datum &key) throw (Curia_error) |
Delete a record. | |
virtual Datum | fetchrec (const Datum &key) throw (Curia_error) |
Fetch a record. | |
virtual Datum | firstkey () throw (Curia_error) |
Get the first key. | |
virtual Datum | nextkey () throw (Curia_error) |
Get the next key. | |
virtual bool | error () throw (Curia_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 (Curia_error) |
Remove a database directory. | |
static char * | snaffle (const char *name, const char *kbuf, int ksiz, int *sp) throw (Curia_error) |
Retrieve a record directly from a database directory. | |
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 sparse files | |
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 Curia, the extended API of QDBM.
qdbm::Curia::Curia | ( | const char * | name, | |
int | omode = Curia::OREADER , |
|||
int | bnum = -1 , |
|||
int | dnum = -1 | |||
) | throw (Curia_error) |
Get the database handle.
name | the name of a database directory. | |
omode | the connection mode: `CuriaOWRITER' as a writer, `CuriaOREADER' as a reader. If the mode is `CuriaOWRITER', the following may be added by bitwise or: `CuriaOCREAT', which means it creates a new database if not exist, `CuriaOTRUNC', which means it creates a new database regardless if one exists. Both of `CuriaOREADER' and `CuriaOWRITER' can be added to by bitwise or: `CuriaONOLCK', which means it opens a database directory without file locking, or `CuriaOLCKNB', which means locking is performed without blocking. `CuriaOCREAT' can be added to by bitwise or: `CuriaOSPARSE', which means it creates database files as sparse files. | |
bnum | the number of elements of each bucket array. If it is not more than 0, the default value is specified. The size of each bucket array is determined on creating, and can not be changed except for by optimization of the database. Suggested size of each bucket array is about from 0.5 to 4 times of the number of all records to store. | |
dnum | the number of division of the database. If it is not more than 0, the default value is specified. The number of division can not be changed from the initial value. The max number of division is 512. |
virtual qdbm::Curia::~Curia | ( | ) | throw () [virtual] |
Release the resources.
virtual int qdbm::Curia::bnum | ( | ) | throw (Curia_error) [virtual] |
Get the total number of the elements of each bucket array.
Curia_error | if an error occurs. |
virtual int qdbm::Curia::busenum | ( | ) | throw (Curia_error) [virtual] |
Get the total number of the used elements of each bucket array.
Curia_error | if an error occurs. |
virtual void qdbm::Curia::close | ( | ) | throw (Curia_error) [virtual] |
Close the database handle.
Curia_error | if an error occurs. |
Implements qdbm::ADBM.
virtual void qdbm::Curia::deleterec | ( | const Datum & | key | ) | throw (Curia_error) [virtual] |
Delete a record.
key | reference to a key object. |
Curia_error | if an error occurs or no record corresponds. |
Implements qdbm::ADBM.
virtual bool qdbm::Curia::error | ( | ) | throw (Curia_error) [virtual] |
Check whether a fatal error occured or not.
Curia_error | if an error occurs. |
Implements qdbm::ADBM.
virtual bool qdbm::Curia::fatalerror | ( | ) | throw (Curia_error) [virtual] |
Check whether the database has a fatal error or not.
Curia_error | if an error occurs. |
virtual Datum qdbm::Curia::fetchrec | ( | const Datum & | key | ) | throw (Curia_error) [virtual] |
Fetch a record.
key | reference to a key object. |
Curia_error | if an error occurs or no record corresponds. |
Implements qdbm::ADBM.
virtual Datum qdbm::Curia::firstkey | ( | ) | throw (Curia_error) [virtual] |
Get the first key.
Curia_error | if an error occurs or no record corresponds. |
Implements qdbm::ADBM.
virtual int qdbm::Curia::fsiz | ( | ) | throw (Curia_error) [virtual] |
Get the total size of database files.
Curia_error | if an error occurs. |
virtual double qdbm::Curia::fsizd | ( | ) | throw (Curia_error) [virtual] |
Get the total size of database files as double-precision floating-point number.
Curia_error | if an error occurs. |
virtual char* qdbm::Curia::get | ( | const char * | kbuf, | |
int | ksiz, | |||
int | start = 0 , |
|||
int | max = -1 , |
|||
int * | sp = 0 | |||
) | throw (Curia_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. |
Curia_error | if an error occurs, no record corresponds, or the size of the value of the corresponding record is less than `start'. |
virtual char* qdbm::Curia::getlob | ( | const char * | kbuf, | |
int | ksiz, | |||
int | start = 0 , |
|||
int | max = -1 , |
|||
int * | sp = 0 | |||
) | throw (Curia_error) [virtual] |
Retrieve a large object.
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. If it is negative, the size to read 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. |
Curia_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::Curia::getlobfd | ( | const char * | kbuf, | |
int | ksiz | |||
) | [virtual] |
Get the file descriptor of a large object.
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)'. |
Curia_error | if an error occurs or no record corresponds. |
virtual int qdbm::Curia::getwb | ( | const char * | kbuf, | |
int | ksiz, | |||
int | start, | |||
int | max, | |||
char * | vbuf | |||
) | throw (Curia_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. |
Curia_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::Curia::inode | ( | ) | throw (Curia_error) [virtual] |
Get the inode number of the database directory.
Curia_error | if an error occurs. |
virtual void qdbm::Curia::iterinit | ( | ) | throw (Curia_error) [virtual] |
Initialize the iterator of the database handle.
Curia_error | if an error occurs. |
virtual char* qdbm::Curia::iternext | ( | int * | sp = 0 |
) | throw (Curia_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. |
Curia_error | if an error occurs or no record is to be get out of the iterator. |
virtual time_t qdbm::Curia::mtime | ( | ) | throw (Curia_error) [virtual] |
Get the last modified time of the database.
Curia_error | if an error occurs. |
virtual char* qdbm::Curia::name | ( | ) | throw (Curia_error) [virtual] |
Get the name of the database.
Curia_error | if an error occurs. |
virtual Datum qdbm::Curia::nextkey | ( | ) | throw (Curia_error) [virtual] |
Get the next key.
Curia_error | if an error occurs or no record corresponds. |
Implements qdbm::ADBM.
virtual void qdbm::Curia::optimize | ( | int | bnum = -1 |
) | throw (Curia_error) [virtual] |
Optimize the database.
bnum | the number of the elements of each bucket array. If it is not more than 0, the default value is specified. |
Curia_error | if an error occurs. |
virtual bool qdbm::Curia::out | ( | const char * | kbuf, | |
int | ksiz | |||
) | throw (Curia_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)'. |
Curia_error | if an error occurs or no record corresponds. |
virtual bool qdbm::Curia::outlob | ( | const char * | kbuf, | |
int | ksiz | |||
) | throw (Curia_error) [virtual] |
Delete a large object.
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)'. |
Curia_error | if an error occurs or no large object corresponds. |
virtual bool qdbm::Curia::put | ( | const char * | kbuf, | |
int | ksiz, | |||
const char * | vbuf, | |||
int | vsiz, | |||
int | dmode = Curia::DOVER | |||
) | throw (Curia_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: `CuriaDOVER', which means the specified value overwrites the existing one, `CuriaDKEEP', which means the existing value is kept, `CuriaDCAT', which means the specified value is concatenated at the end of the existing value. |
Curia_error | if an error occurs or replace is cancelled. |
virtual bool qdbm::Curia::putlob | ( | const char * | kbuf, | |
int | ksiz, | |||
const char * | vbuf, | |||
int | vsiz, | |||
int | dmode = Curia::DOVER | |||
) | throw (Curia_error) [virtual] |
Store a large object.
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: `CuriaDOVER', which means the specified value overwrites the existing one, `CuriaDKEEP', which means the existing value is kept, `CuriaDCAT', which means the specified value is concatenated at the end of the existing value. |
Curia_error | if an error occurs or replace is cancelled. |
static void qdbm::Curia::remove | ( | const char * | name | ) | throw (Curia_error) [static] |
Remove a database directory.
name | the name of a database directory. |
Curia_error | if an error occurs. |
virtual int qdbm::Curia::rnum | ( | ) | throw (Curia_error) [virtual] |
Get the number of the records stored in the database.
Curia_error | if an error occurs. |
virtual int qdbm::Curia::rnumlob | ( | ) | throw (Curia_error) [virtual] |
Get the number of the large objects stored in the database.
Curia_error | if an error occurs. |
virtual void qdbm::Curia::setalign | ( | int | align | ) | throw (Curia_error) [virtual] |
Set alignment of the database handle.
align | the basic size of alignment. |
Curia_error | if an error occurs. |
virtual void qdbm::Curia::setfbpsiz | ( | int | size | ) | throw (Curia_error) [virtual] |
Set the size of the free block pool.
size | the size of the free block pool of a database. |
Curia_error | if an error occurs. |
static char* qdbm::Curia::snaffle | ( | const char * | name, | |
const char * | kbuf, | |||
int | ksiz, | |||
int * | sp | |||
) | throw (Curia_error) [static] |
Retrieve a record directly from a database directory.
name | the name of a database directory. | |
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. |
Curia_error | if an error occurs or no record corresponds. |
virtual void qdbm::Curia::storerec | ( | const Datum & | key, | |
const Datum & | val, | |||
bool | replace = true | |||
) | throw (Curia_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. |
Curia_error | if an error occurs or replace is cancelled. |
Implements qdbm::ADBM.
virtual void qdbm::Curia::sync | ( | ) | throw (Curia_error) [virtual] |
Synchronize updating contents with the files and the devices.
static const char* qdbm::Curia::version | ( | ) | throw () [static] |
Get the version information.
virtual int qdbm::Curia::vsiz | ( | const char * | kbuf, | |
int | ksiz | |||
) | throw (Curia_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)'. |
Curia_error | if an error occurs or no record corresponds. |
virtual int qdbm::Curia::vsizlob | ( | const char * | kbuf, | |
int | ksiz | |||
) | throw (Curia_error) [virtual] |
Get the size of the value of a large object.
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)'. |
Curia_error | if an error occurs or no large object corresponds. |
virtual bool qdbm::Curia::writable | ( | ) | throw (Curia_error) [virtual] |
Check whether the database handle is a writer or not.
Curia_error | if an error occurs. |