Polymorphic database. More...
#include <kcpolydb.h>
Classes | |
class | Cursor |
Cursor to indicate a record. More... | |
Public Member Functions | |
PolyDB () | |
Default constructor. | |
PolyDB (FileDB *db) | |
Constructor. | |
virtual | ~PolyDB () |
Destructor. | |
virtual bool | accept (const char *kbuf, size_t ksiz, Visitor *visitor, bool writable=true) |
Accept a visitor to a record. | |
virtual bool | iterate (Visitor *visitor, bool writable=true) |
Iterate to accept a visitor for each record. | |
virtual Error | error () const |
Get the last happened error. | |
virtual void | set_error (Error::Code code, const char *message) |
Set the error information. | |
virtual bool | open (const std::string &path, uint32_t mode=OWRITER|OCREATE) |
Open a database file. | |
virtual bool | close () |
Close the database file. | |
virtual bool | synchronize (bool hard=false, FileProcessor *proc=NULL) |
Synchronize updated contents with the file and the device. | |
virtual bool | begin_transaction (bool hard=false) |
Begin transaction. | |
virtual bool | begin_transaction_try (bool hard=false) |
Try to begin transaction. | |
virtual bool | end_transaction (bool commit=true) |
End transaction. | |
virtual bool | clear () |
Remove all records. | |
virtual int64_t | count () |
Get the number of records. | |
virtual int64_t | size () |
Get the size of the database file. | |
virtual std::string | path () |
Get the path of the database file. | |
virtual bool | status (std::map< std::string, std::string > *strmap) |
Get the miscellaneous status information. | |
virtual Cursor * | cursor () |
Create a cursor object. | |
virtual FileDB * | reveal_inner_db () |
Reveal the inner database object. |
Polymorphic database.
kyotocabinet::PolyDB::PolyDB | ( | ) |
Default constructor.
kyotocabinet::PolyDB::PolyDB | ( | FileDB * | db | ) |
Constructor.
db | the internal database object. Its possession is transferred inside and the object is deleted automatically. |
virtual kyotocabinet::PolyDB::~PolyDB | ( | ) | [virtual] |
Destructor.
virtual bool kyotocabinet::PolyDB::accept | ( | const char * | kbuf, | |
size_t | ksiz, | |||
Visitor * | visitor, | |||
bool | writable = true | |||
) | [virtual] |
Accept a visitor to a record.
kbuf | the pointer to the key region. | |
ksiz | the size of the key region. | |
visitor | a visitor object. | |
writable | true for writable operation, or false for read-only operation. |
Implements kyotocabinet::DB.
virtual bool kyotocabinet::PolyDB::iterate | ( | Visitor * | visitor, | |
bool | writable = true | |||
) | [virtual] |
Iterate to accept a visitor for each record.
visitor | a visitor object. | |
writable | true for writable operation, or false for read-only operation. |
Implements kyotocabinet::DB.
virtual Error kyotocabinet::PolyDB::error | ( | ) | const [virtual] |
virtual void kyotocabinet::PolyDB::set_error | ( | Error::Code | code, | |
const char * | message | |||
) | [virtual] |
Set the error information.
code | an error code. | |
message | a supplement message. |
virtual bool kyotocabinet::PolyDB::open | ( | const std::string & | path, | |
uint32_t | mode = OWRITER | OCREATE | |||
) | [virtual] |
Open a database file.
path | the path of a database file. If it is "-", the database will be a prototype hash database. If it is "+", the database will be a prototype tree database. If it is "*", the database will be a cache database. If its suffix is ".kch", the database will be a file hash database. If its suffix is ".kct", the database will be a file tree database. Otherwise, this function fails. Tuning parameters can trail the name, separated by "#". Each parameter is composed of the name and the value, separated by "=". If the "type" parameter is specified, the database type is determined by the value in "-", "+", "*", "kch", and "kct". The prototype hash hash database and the prototype tree database do not support any other tuning parameter. The cache database supports "bnum", "capcount", and "capsize". The file hash database supports "apow", "fpow", "opts", "bnum", "msiz", "dfunit", "erstrm", and "ervbs". The file tree database supports all parameters of the file hash database and "psiz", "rcomp", "pccap" in addition. | |
mode | the connection mode. PolyDB::OWRITER as a writer, PolyDB::OREADER as a reader. The following may be added to the writer mode by bitwise-or: PolyDB::OCREATE, which means it creates a new database if the file does not exist, PolyDB::OTRUNCATE, which means it creates a new database regardless if the file exists, PolyDB::OAUTOTRAN, which means each updating operation is performed in implicit transaction, PolyDB::OAUTOSYNC, which means each updating operation is followed by implicit synchronization with the file system. The following may be added to both of the reader mode and the writer mode by bitwise-or: PolyDB::ONOLOCK, which means it opens the database file without file locking, PolyDB::OTRYLOCK, which means locking is performed without blocking, PolyDB::ONOREPAIR, which means the database file is not repaired implicitly even if file destruction is detected. |
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::PolyDB::close | ( | ) | [virtual] |
Close the database file.
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::PolyDB::synchronize | ( | bool | hard = false , |
|
FileProcessor * | proc = NULL | |||
) | [virtual] |
Synchronize updated contents with the file and the device.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. | |
proc | a postprocessor object. If it is NULL, no postprocessing is performed. |
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::PolyDB::begin_transaction | ( | bool | hard = false |
) | [virtual] |
Begin transaction.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. |
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::PolyDB::begin_transaction_try | ( | bool | hard = false |
) | [virtual] |
Try to begin transaction.
hard | true for physical synchronization with the device, or false for logical synchronization with the file system. |
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::PolyDB::end_transaction | ( | bool | commit = true |
) | [virtual] |
End transaction.
commit | true to commit the transaction, or false to abort the transaction. |
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::PolyDB::clear | ( | ) | [virtual] |
virtual int64_t kyotocabinet::PolyDB::count | ( | ) | [virtual] |
Get the number of records.
Implements kyotocabinet::DB.
virtual int64_t kyotocabinet::PolyDB::size | ( | ) | [virtual] |
Get the size of the database file.
Implements kyotocabinet::FileDB.
virtual std::string kyotocabinet::PolyDB::path | ( | ) | [virtual] |
Get the path of the database file.
Implements kyotocabinet::FileDB.
virtual bool kyotocabinet::PolyDB::status | ( | std::map< std::string, std::string > * | strmap | ) | [virtual] |
Get the miscellaneous status information.
strmap | a string map to contain the result. |
Implements kyotocabinet::FileDB.
virtual Cursor* kyotocabinet::PolyDB::cursor | ( | ) | [virtual] |
Create a cursor object.
Implements kyotocabinet::FileDB.
virtual FileDB* kyotocabinet::PolyDB::reveal_inner_db | ( | ) | [virtual] |
Reveal the inner database object.