Provides indexed storage for multiple records using two files (a binary data file and a text index file).
More...
|
| drwnPersistentStorage (bool bCompressed=false) |
|
| drwnPersistentStorage (const drwnPersistentStorage &storage) |
|
bool | open (const char *indexFile, const char *dataFile) |
| open persistent storage index and data files
|
|
bool | open (const char *fileStem) |
| open persistent storage using default extension for index and data files
|
|
bool | reopen () |
| re-open previously opened persistent storage files
|
|
bool | close () |
| close (and write) persistent storage files
|
|
bool | isOpen () const |
| returns true if the persistent storage has been opened and not closed
|
|
bool | canReopen () const |
| returns true if the persistent storage object has valid filenames but is currently closed
|
|
int | numRecords () const |
| number of drwnPersistentRecord records stored on disk
|
|
size_t | numTotalBytes () const |
| total number of bytes on disk used by the data file
|
|
size_t | numUsedBytes () const |
| number of bytes on disk actually needed by the data file
|
|
size_t | numFreeBytes () const |
| number of free bytes (due to fragmentation) in data file
|
|
bool | hasKey (const char *key) const |
| returns true if a record with given key exists in the persistent storage
|
|
set< string > | getKeys () const |
| returns all keys stored in the persistent storage object
|
|
bool | erase (const char *key) |
| erases the record with given key
|
|
bool | read (const char *key, drwnPersistentRecord *record) |
| reads the record with given key
|
|
bool | write (const char *key, const drwnPersistentRecord *record) |
| writes the record with given key
|
|
size_t | bytes (const char *key) const |
| number of bytes on disk used for record with given key
|
|
bool | clear () |
| clears all records from the persistent storage object (takes affect when closed)
|
|
bool | defragment () |
| defragments data file
|
|
Provides indexed storage for multiple records using two files (a binary data file and a text index file).
The class maintains an open stream to the data file. The index file is written on closing. A closed storage object can be reopened without having to re-parse the index file. The class also manages the maximum number of actively open storage objects. If more storage objects are opened, the oldest ones will be suspended (temporarily closes). Any operation to the storage object will automatically re-open (resume) the storage (possibly suspending other storage objects). To use this class, objects must implement the drwnPersistentRecord interface. Automatic compression of records can be set and is managed by through the drwnCompressionBuffer class.
The erase(), read() and write() methods are thread-safe allowing the same persistent storage object to be accessed from multiple threads.
- See also
- Darwin Tutorial for an example.