Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
CDB Class Reference

RAII class that provides access to a Berkeley database. More...

#include <db.h>

+ Inheritance diagram for CDB:
+ Collaboration diagram for CDB:

Public Member Functions

void Flush ()
 
void Close ()
 
bool TxnBegin ()
 
bool TxnCommit ()
 
bool TxnAbort ()
 
bool ReadVersion (int &nVersion)
 
bool WriteVersion (int nVersion)
 

Static Public Member Functions

static bool Rewrite (const std::string &strFile, const char *pszSkip=NULL)
 

Protected Member Functions

 CDB (const char *pszFile, const char *pszMode="r+")
 
 ~CDB ()
 
template<typename K , typename T >
bool Read (const K &key, T &value)
 
template<typename K , typename T >
bool Write (const K &key, const T &value, bool fOverwrite=true)
 
template<typename K >
bool Erase (const K &key)
 
template<typename K >
bool Exists (const K &key)
 
Dbc * GetCursor ()
 
int ReadAtCursor (Dbc *pcursor, CDataStream &ssKey, CDataStream &ssValue, unsigned int fFlags=DB_NEXT)
 

Protected Attributes

Db * pdb
 
std::string strFile
 
DbTxn * activeTxn
 
bool fReadOnly
 

Private Member Functions

 CDB (const CDB &)
 
void operator= (const CDB &)
 

Detailed Description

RAII class that provides access to a Berkeley database.

Definition at line 90 of file db.h.

Constructor & Destructor Documentation

CDB::CDB ( const char *  pszFile,
const char *  pszMode = "r+" 
)
explicitprotected

Definition at line 224 of file db.cpp.

References CLIENT_VERSION, CDBEnv::cs_db, CDBEnv::dbenv, Exists(), fReadOnly, GetDataDir(), CDBEnv::IsMock(), LOCK, CDBEnv::mapDb, CDBEnv::mapFileUseCount, CDBEnv::Open(), pdb, strFile, strprintf, and WriteVersion().

+ Here is the call graph for this function:

CDB::~CDB ( )
inlineprotected

Definition at line 99 of file db.h.

References Close().

+ Here is the call graph for this function:

CDB::CDB ( const CDB )
private

Member Function Documentation

void CDB::Close ( )

Definition at line 300 of file db.cpp.

References activeTxn, CDBEnv::cs_db, Flush(), LOCK, CDBEnv::mapFileUseCount, pdb, and strFile.

Referenced by ~CDB().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<typename K >
bool CDB::Erase ( const K &  key)
inlineprotected

Definition at line 173 of file db.h.

References CLIENT_VERSION, CDataStream::reserve(), SER_DISK, and CDataStream::size().

+ Here is the call graph for this function:

template<typename K >
bool CDB::Exists ( const K &  key)
inlineprotected

Definition at line 195 of file db.h.

References CLIENT_VERSION, CDataStream::reserve(), SER_DISK, and CDataStream::size().

Referenced by CDB().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CDB::Flush ( )

Definition at line 287 of file db.cpp.

References activeTxn, CDBEnv::dbenv, fReadOnly, and GetArg().

Referenced by Close().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Dbc* CDB::GetCursor ( )
inlineprotected

Definition at line 214 of file db.h.

void CDB::operator= ( const CDB )
private
template<typename K , typename T >
bool CDB::Read ( const K &  key,
T &  value 
)
inlineprotected

Definition at line 109 of file db.h.

References CLIENT_VERSION, CDataStream::reserve(), SER_DISK, and CDataStream::size().

Referenced by ReadVersion().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int CDB::ReadAtCursor ( Dbc *  pcursor,
CDataStream ssKey,
CDataStream ssValue,
unsigned int  fFlags = DB_NEXT 
)
inlineprotected

Definition at line 225 of file db.h.

References CDataStream::clear(), SER_DISK, CDataStream::SetType(), CDataStream::size(), and CDataStream::write().

+ Here is the call graph for this function:

bool CDB::ReadVersion ( int nVersion)
inline

Definition at line 294 of file db.h.

References Read().

+ Here is the call graph for this function:

bool CDB::Rewrite ( const std::string &  strFile,
const char *  pszSkip = NULL 
)
static

Definition at line 341 of file db.cpp.

References CDBEnv::CheckpointLSN(), CDataStream::clear(), CLIENT_VERSION, CDBEnv::CloseDb(), CDBEnv::cs_db, CDBEnv::dbenv, LOCK, LogPrintf, CDBEnv::mapFileUseCount, MilliSleep(), SER_DISK, CDataStream::size(), and strFile.

Referenced by CWallet::EncryptWallet(), CWallet::LoadWallet(), and CWallet::ZapWalletTx().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CDB::TxnAbort ( )
inline

Definition at line 285 of file db.h.

bool CDB::TxnBegin ( )
inline

Definition at line 265 of file db.h.

References CDBEnv::TxnBegin().

Referenced by movecmd().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CDB::TxnCommit ( )
inline

Definition at line 276 of file db.h.

Referenced by movecmd().

+ Here is the caller graph for this function:

template<typename K , typename T >
bool CDB::Write ( const K &  key,
const T &  value,
bool  fOverwrite = true 
)
inlineprotected

Definition at line 144 of file db.h.

References CLIENT_VERSION, CDataStream::reserve(), SER_DISK, and CDataStream::size().

Referenced by WriteVersion().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CDB::WriteVersion ( int  nVersion)
inline

Definition at line 300 of file db.h.

References Write().

Referenced by CDB().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

DbTxn* CDB::activeTxn
protected

Definition at line 95 of file db.h.

Referenced by Close(), and Flush().

bool CDB::fReadOnly
protected

Definition at line 96 of file db.h.

Referenced by CDB(), and Flush().

Db* CDB::pdb
protected

Definition at line 93 of file db.h.

Referenced by CDB(), and Close().

std::string CDB::strFile
protected

Definition at line 94 of file db.h.

Referenced by CDB(), Close(), and Rewrite().


The documentation for this class was generated from the following files: