#include <wvondiskhash.h>
Inheritance diagram for WvBdbHash:
Definition at line 286 of file wvondiskhash.h.
Public Types | |
typedef datum | Datum |
Public Member Functions | |
WvBdbHash (WvStringParm _dbfile=WvString::null, bool persist=true) | |
void | opendb (WvStringParm _dbfile=WvString::null, bool persist=true) |
Open a new db file. | |
void | closedb () |
Close the db file. | |
void | add (const datum &key, const datum &data, bool replace) |
void | remove (const datum &key) |
datum | find (const datum &key) |
bool | exists (const datum &key) |
void | zap () |
Wipe the db. | |
virtual bool | isok () const |
By default, returns true if geterr() == 0. | |
virtual int | geterr () const |
If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file. | |
virtual WvString | errstr () const |
virtual void | seterr (int _errnum) |
Set the errnum variable -- we have an error. | |
void | seterr (WvStringParm specialerr) |
void | seterr (WVSTRING_FORMAT_DECL) |
void | seterr (const WvErrorBase &err) |
void | seterr_both (int _errnum, WvStringParm specialerr) |
void | noerr () |
Reset our error state - there's no error condition anymore. | |
Static Public Member Functions | |
static WvString | strerror (int errnum) |
A replacement for the operating system strerror() function that can map more kinds of error strings (especially in win32). | |
Protected Attributes | |
int | errnum |
WvString | errstring |
Friends | |
class | IterBase |
Classes | |
struct | datum |
class | IterBase |
void WvBdbHash::opendb | ( | WvStringParm | _dbfile = WvString::null , |
|
bool | persist = true | |||
) |
Open a new db file.
This will instantly change the contents of the db, and probably mess up all your iterators. Best used just after creation.
if dbfile is NULL, bdb will create an "anonymous" database. It'll still take up disk space, but it disappears when closed. If dbfile is not NULL but persist_dbfile is false, the file will be truncated when opened and deleted when closed.
It is ok to use this if !isok - in fact, it's the expected way to reset it. It may fail and seterr itself, though, so don't get stuck in a loop.
void WvBdbHash::closedb | ( | ) |
Close the db file.
Makes isok return false, so you must call opendb() before using it again. The effect on open iterators is undefined.
This can be called when !isok. It will always set the error message to "The db is closed" if it succeeds; if it sets it to anything else, there was an error while flushing the db.
void WvBdbHash::zap | ( | ) |
Wipe the db.
Calling this while !isok is allowed, but not guaranteed to fix it.
virtual bool WvErrorBase::isok | ( | ) | const [inline, virtual, inherited] |
By default, returns true if geterr() == 0.
Might be overridden so that isok() == false even though no error code has been specified.
Reimplemented in IWvStream, WvBufStream, WvDSAKey, WvDsp, WvEncoderStream, WvFdStream, WvHTTPStream, WvIStreamList, WvLog, WvRSAKey, WvSSLStream, WvStream, WvStreamClone, WvTCPConn, WvTimeoutStream, WvTimeStream, WvFileWatcher, WvX509Mgr, and _WvConStream.
Definition at line 39 of file wverror.h.
References WvErrorBase::errnum.
Referenced by WvX509Mgr::isok(), WvStream::isok(), WvCRLMgr::isok(), WvGlob::set(), and WvGlobDirIter::WvGlobDirIter().
virtual int WvErrorBase::geterr | ( | ) | const [inline, virtual, inherited] |
If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.
If isok() is true, returns an undefined number.
Reimplemented in WvHTTPStream, WvStreamClone, and WvX509Mgr.
Definition at line 48 of file wverror.h.
References WvErrorBase::errnum.
Referenced by UniIniGen::commit(), WvX509Mgr::errstr(), WvStreamClone::errstr(), WvErrorBase::errstr(), WvError::get(), UniFileSystemGen::get(), WvX509Mgr::geterr(), WvStreamClone::geterr(), WvEncoderStream::isok(), WvConf::load_file(), WvLockDev::lock(), WvHTTPStream::pre_select(), UniIniGen::refresh(), WvConf::save(), WvStream::seterr(), WvErrorBase::seterr(), WvMagicCircle::WvMagicCircle(), and WvHttpPool::~WvHttpPool().
void WvErrorBase::seterr | ( | int | _errnum | ) | [virtual, inherited] |
Set the errnum variable -- we have an error.
If called more than once, seterr() doesn't change the error code away from the previous one. That way, we remember the _original_ cause of our problems.
Subclasses may want to override seterr(int) to shut themselves down (eg. WvStream::close()) when an error condition is set.
Note that seterr(WvString) will call seterr(-1).
Reimplemented in WvStream.
Definition at line 144 of file wverror.cc.
References WvErrorBase::errstring.
Referenced by WvX509Mgr::certreq(), WvX509Mgr::create_selfsigned(), WvX509Mgr::decode(), WvCRLMgr::decode(), WvX509Mgr::encode(), WvCRLMgr::encode(), WvRSAKey::getpem(), WvDSAKey::getpem(), WvX509Mgr::read_p12(), WvGlob::set(), WvError::set(), WvX509Mgr::set_pubkey(), WvStream::seterr(), WvErrorBase::seterr(), WvErrorBase::seterr_both(), WvX509Mgr::sign(), WvX509Mgr::signedbyCAinfile(), WvX509Mgr::test(), WvX509Mgr::unhexify(), WvX509Mgr::validate(), WvX509Mgr::verify(), WvX509Mgr::write_p12(), WvCRLMgr::WvCRLMgr(), WvDSAKey::WvDSAKey(), WvMagicCircle::WvMagicCircle(), WvPam::WvPam(), WvRSAKey::WvRSAKey(), WvShmZone::WvShmZone(), and WvX509Mgr::WvX509Mgr().