Main Page | Namespace List | Class List | File List | Class Members | File Members | Related Pages

Constant::Datastore Class Reference

#include <datastore.h>

Collaboration diagram for Constant::Datastore:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Datastore ()
 Datastore (const std::string &filen)
 ~Datastore ()
std::string fetch (const std::string &key_val)
std::string fetch_next ()
void setdb (const std::string &filen)
std::string operator[] (const std::string &)
void initlog (const std::string &logfilen)
void log (const std::string &, const std::string &)
void commitlog ()
void commitlog (const std::string &)
void backupdb ()
void dump (const std::string &dumpfilename)
std::pair< std::string, std::string > first ()
std::pair< std::string, std::string > next ()

Detailed Description

Datastore is a c++ class providing access to DJB style constant db (cdb). The class really on has one method fetch that takes a string and returns a string

Definition at line 28 of file datastore.h.


Constructor & Destructor Documentation

Constant::Datastore::Datastore  ) 
 

Default constructor. Intialized everything to zero

Constant::Datastore::Datastore const std::string &  filen  ) 
 

constructor that sets the cdb to be filename

Parameters:
filen -- file name for cdb

Constant::Datastore::~Datastore  ) 
 


Member Function Documentation

void Constant::Datastore::backupdb  ) 
 

writes a backup of the current database in the form of DBFILENAME. where is the next highest number. It will fill in gaps, if you have backups of 1 2 3 5, the next sequence is 4

Exceptions:
CANTBACKUPDB 
Todo:
backupdb and statdb need to be gerneralized for any file

void Constant::Datastore::commitlog const std::string &   ) 
 

Commit log with an argument sets the database to the name given by the argument and commits the log and sets the current database name

void Constant::Datastore::commitlog  ) 
 

Commit log writes the information contained in the log to the current database. It does not Add to the current database. This is an atomic replacement

void Constant::Datastore::dump const std::string &  dumpfilename  ) 
 

dump out the current database in cdbmake format to the filename given by dumpfilename

Parameters:
dumpfilename This is the name of the file to dump the current database to

std::string Constant::Datastore::fetch const std::string &  key_val  ) 
 

Parameters:
key_val -- key to find in the database. returns an empty string if nothing found, or database is bad

std::string Constant::Datastore::fetch_next  ) 
 

fetches the next value stored for the previous key

std::pair<std::string,std::string> Constant::Datastore::first  ) 
 

returns the first key->value pair in the database and sets things up so you can call next. Returns empty strings in the pair if there is no first key.

void Constant::Datastore::initlog const std::string &  logfilen  ) 
 

Open the log and set up for logging operations

Parameters:
logfilen -- the filename to open

void Constant::Datastore::log const std::string &  ,
const std::string & 
 

add entry to the log. This takes the key and data string and writes a log entry in cdb_make format

std::pair<std::string,std::string> Constant::Datastore::next  ) 
 

returns the next key in the database, used with first. Returns empty strings in the pair at the end.

std::string Constant::Datastore::operator[] const std::string &   ) 
 

convienince operator to provide DATA = db[KEY] style use

void Constant::Datastore::setdb const std::string &  filen  ) 
 

Parameters:
filen -- set db to file reinitialized db if there's one already there


The documentation for this class was generated from the following file:
Generated on Mon Apr 26 09:49:28 2004 for ConstantDataStore by doxygen 1.3.6-20040222