Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cargo::KVStore Class Reference

#include <kvstore.hpp>

Classes

class  Transaction
 A guard struct for thread synchronization and transaction management. More...
 

Public Member Functions

 KVStore (const std::string &path)
 
 ~KVStore ()
 
 KVStore (const KVStore &)=delete
 
KVStoreoperator= (const KVStore &)=delete
 
void clear ()
 Clears all the stored data. More...
 
bool isEmpty ()
 
bool exists (const std::string &key)
 
bool prefixExists (const std::string &key)
 
void remove (const std::string &key)
 Removes values corresponding to the passed key. More...
 
void set (const std::string &key, const std::string &value)
 Stores a single value corresponding to the passed key. More...
 
std::string get (const std::string &key)
 Gets the value corresponding to the key. More...
 
std::vector< std::string > getKeys ()
 Returns all stored keys. More...
 

Private Types

typedef std::lock_guard
< std::recursive_mutex > 
Lock
 

Private Member Functions

void setupDb ()
 
void prepareStatements ()
 
void createFunctions ()
 

Private Attributes

std::recursive_mutex mMutex
 
size_t mTransactionDepth
 
bool mIsTransactionCommited
 
std::string mPath
 
sqlite3::Connection mConn
 
std::unique_ptr
< sqlite3::Statement
mGetValueStmt
 
std::unique_ptr
< sqlite3::Statement
mGetKeyExistsStmt
 
std::unique_ptr
< sqlite3::Statement
mGetKeyPrefixExistsStmt
 
std::unique_ptr
< sqlite3::Statement
mGetIsEmptyStmt
 
std::unique_ptr
< sqlite3::Statement
mGetValueListStmt
 
std::unique_ptr
< sqlite3::Statement
mSetValueStmt
 
std::unique_ptr
< sqlite3::Statement
mRemoveValuesStmt
 
std::unique_ptr
< sqlite3::Statement
mGetKeysStmt
 

Member Typedef Documentation

typedef std::lock_guard<std::recursive_mutex> cargo::KVStore::Lock
private

Constructor & Destructor Documentation

cargo::KVStore::KVStore ( const std::string &  path)
explicit
Parameters
pathconfiguration database file path
cargo::KVStore::~KVStore ( )
cargo::KVStore::KVStore ( const KVStore )
delete

Member Function Documentation

void cargo::KVStore::clear ( )

Clears all the stored data.

void cargo::KVStore::createFunctions ( )
private
bool cargo::KVStore::exists ( const std::string &  key)
Parameters
keystring of the stored value
Returns
Does this key exist in the database
std::string cargo::KVStore::get ( const std::string &  key)

Gets the value corresponding to the key.

Parameters
keystring key of the value
Returns
value corresponding to the key
std::vector< std::string > cargo::KVStore::getKeys ( )

Returns all stored keys.

bool cargo::KVStore::isEmpty ( )
Returns
Is there any data stored
KVStore& cargo::KVStore::operator= ( const KVStore )
delete
bool cargo::KVStore::prefixExists ( const std::string &  key)
Parameters
keystring of the stored value
Returns
Does a key starting with an argument exist in the database
void cargo::KVStore::prepareStatements ( )
private
void cargo::KVStore::remove ( const std::string &  key)

Removes values corresponding to the passed key.

Many values may correspond to one key, so many values may need to be deleted

Parameters
keystring regexp of the stored values
void cargo::KVStore::set ( const std::string &  key,
const std::string &  value 
)

Stores a single value corresponding to the passed key.

Parameters
keystring key of the value
valuevalue corresponding to the key
void cargo::KVStore::setupDb ( )
private

Member Data Documentation

sqlite3::Connection cargo::KVStore::mConn
private
std::unique_ptr<sqlite3::Statement> cargo::KVStore::mGetIsEmptyStmt
private
std::unique_ptr<sqlite3::Statement> cargo::KVStore::mGetKeyExistsStmt
private
std::unique_ptr<sqlite3::Statement> cargo::KVStore::mGetKeyPrefixExistsStmt
private
std::unique_ptr<sqlite3::Statement> cargo::KVStore::mGetKeysStmt
private
std::unique_ptr<sqlite3::Statement> cargo::KVStore::mGetValueListStmt
private
std::unique_ptr<sqlite3::Statement> cargo::KVStore::mGetValueStmt
private
bool cargo::KVStore::mIsTransactionCommited
private
std::recursive_mutex cargo::KVStore::mMutex
private
std::string cargo::KVStore::mPath
private
std::unique_ptr<sqlite3::Statement> cargo::KVStore::mRemoveValuesStmt
private
std::unique_ptr<sqlite3::Statement> cargo::KVStore::mSetValueStmt
private
size_t cargo::KVStore::mTransactionDepth
private

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