SQLite Containers
Loading...
Searching...
No Matches
sqlite_containers Namespace Reference

Classes

class  BaseDB
 Base class for SQLite database management. More...
 
class  Config
 Configuration class for SQLite database settings. More...
 
class  KeyDB
 Template class for managing keys in a SQLite database. More...
 
class  KeyMultiValueDB
 Template class for managing key-value pairs in a SQLite database, where each key can map to multiple values. More...
 
class  KeyValueDB
 Template class for managing key-value pairs in a SQLite database. More...
 
class  sqlite_exception
 Exception class for SQLite errors. More...
 
class  SqliteStmt
 Class for managing SQLite prepared statements. More...
 

Enumerations

enum class  JournalMode {
  DELETE_MODE , TRUNCATE , PERSIST , MEMORY ,
  WAL , OFF
}
 SQLite journal modes enumeration. More...
 
enum class  SynchronousMode { OFF , NORMAL , FULL , EXTRA }
 SQLite synchronous modes enumeration. More...
 
enum class  LockingMode { NORMAL , EXCLUSIVE }
 SQLite locking modes enumeration. More...
 
enum class  AutoVacuumMode { NONE , FULL , INCREMENTAL }
 SQLite auto-vacuum modes enumeration. More...
 
enum class  TempStore { DEFAULT , FILE , MEMORY }
 SQLite temporary storage modes enumeration. More...
 
enum class  TransactionMode { DEFERRED , IMMEDIATE , EXCLUSIVE }
 Defines SQLite transaction modes. More...
 

Functions

std::string to_string (const JournalMode &mode)
 Converts JournalMode enum to string representation.
 
std::string to_string (const SynchronousMode &mode)
 Converts SynchronousMode enum to string representation.
 
std::string to_string (const LockingMode &mode)
 Converts LockingMode enum to string representation.
 
std::string to_string (const AutoVacuumMode &mode)
 Converts AutoVacuumMode enum to string representation.
 
std::string to_string (const TransactionMode &mode)
 Converts TransactionMode enum to string representation.
 
void execute (sqlite3_stmt *stmt)
 Executes a SQLite statement.
 
void execute (sqlite3 *sqlite_db, sqlite3_stmt *stmt)
 Executes a SQLite statement.
 
void execute (sqlite3 *sqlite_db, const char *query)
 Prepares and executes a SQLite statement given as a string.
 
void execute (sqlite3 *sqlite_db, const std::string &query)
 Prepares and executes a SQLite statement given as a string.
 
template<typename T >
std::string get_sqlite_type (typename std::enable_if< std::is_integral< T >::value >::type *=0)
 Gets the SQLite data type as a string for the given type.
 
template<typename T >
std::string get_sqlite_type (typename std::enable_if< std::is_floating_point< T >::value >::type *=0)
 
template<typename T >
std::string get_sqlite_type (typename std::enable_if< std::is_same< T, std::string >::value >::type *=0)
 
template<typename T >
std::string get_sqlite_type (typename std::enable_if< !std::is_integral< T >::value &&!std::is_floating_point< T >::value &&std::is_trivially_copyable< T >::value >::type *=0)
 
template<typename T >
std::enable_if< std::is_trivially_copyable< typenameT::value_type >::value &&std::is_same< T, std::vector< typenameT::value_type > >::value, std::string >::type get_sqlite_type ()
 
template<typename T >
std::enable_if< std::is_trivially_copyable< typenameT::value_type >::value &&std::is_same< T, std::deque< typenameT::value_type > >::value, std::string >::type get_sqlite_type ()
 
template<template< class... > class ContainerT, class T >
void add_value (ContainerT< T > &container, T &value, typename std::enable_if< std::is_same< ContainerT< T >, std::set< T > >::value||std::is_same< ContainerT< T >, std::unordered_set< T > >::value >::type *=0)
 Adds a value to a container (set or unordered_set).
 
template<template< class... > class ContainerT, class T >
void add_value (ContainerT< T > &container, const T &value, const size_t &value_count=0, typename std::enable_if< std::is_same< ContainerT< T >, std::multiset< T > >::value||std::is_same< ContainerT< T >, std::unordered_multiset< T > >::value >::type *=0)
 Adds a value to a container (multiset or unordered_multiset).
 
template<template< class... > class ContainerT, class T >
void add_value (ContainerT< T > &container, T &value, typename std::enable_if< std::is_same< ContainerT< T >, std::list< T > >::value||std::is_same< ContainerT< T >, std::vector< T > >::value||std::is_same< ContainerT< T >, std::deque< T > >::value >::type *=0)
 Adds a value to a container (list, vector, or deque).
 
template<template< class... > class ContainerT, class T >
void add_value (ContainerT< T > &container, const T &value, const size_t &value_count, typename std::enable_if< std::is_same< ContainerT< T >, std::list< T > >::value||std::is_same< ContainerT< T >, std::vector< T > >::value||std::is_same< ContainerT< T >, std::deque< T > >::value >::type *=0)
 Adds a value to a container (list, vector, or deque).
 
template<template< class... > class ContainerT, class T >
void add_value (ContainerT< T > &container, const T &value, const size_t &value_count, typename std::enable_if< std::is_same< ContainerT< T >, std::set< T > >::value||std::is_same< ContainerT< T >, std::multiset< T > >::value||std::is_same< ContainerT< T >, std::unordered_set< T > >::value||std::is_same< ContainerT< T >, std::unordered_multiset< T > >::value >::type *=0)
 Adds a value to a container (std::set).
 
template<template< class... > class ContainerT, typename KeyT , typename ValueT >
void add_value (ContainerT< KeyT, ValueT > &container, KeyT &key, ValueT &value, const size_t &value_count, typename std::enable_if< std::is_same< ContainerT< KeyT, ValueT >, std::multimap< KeyT, ValueT > >::value||std::is_same< ContainerT< KeyT, ValueT >, std::unordered_multimap< KeyT, ValueT > >::value >::type *=0)
 Adds a key-value pair to a container (multimap or unordered_multimap).
 
template<template< class... > class ContainerT, typename KeyT , typename ValueT >
std::list< ValueT > get_values (ContainerT< KeyT, ValueT > &container, const KeyT &key, typename std::enable_if< std::is_same< ContainerT< KeyT, ValueT >, std::map< KeyT, ValueT > >::value||std::is_same< ContainerT< KeyT, ValueT >, std::unordered_map< KeyT, ValueT > >::value >::type *=0)
 Retrieves values from a container (map or unordered_map) based on the key.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT, typename KeyT , typename ValueT >
std::list< ValueT > get_values (ContainerT< KeyT, ValueContainerT< ValueT > > &container, const KeyT &key, typename std::enable_if< std::is_same< ContainerT< KeyT, ValueT >, std::map< KeyT, ValueContainerT< ValueT > > >::value||std::is_same< ContainerT< KeyT, ValueT >, std::unordered_map< KeyT, ValueContainerT< ValueT > > >::value >::type *=0)
 Retrieves values from a container (map or unordered_map) based on the key.
 
template<template< class... > class ContainerT, typename KeyT , typename ValueT >
std::list< ValueT > get_values (ContainerT< KeyT, ValueT > &container, const KeyT &key, typename std::enable_if< std::is_same< ContainerT< KeyT, ValueT >, std::multimap< KeyT, ValueT > >::value||std::is_same< ContainerT< KeyT, ValueT >, std::unordered_multimap< KeyT, ValueT > >::value >::type *=0)
 Retrieves values from a container (multimap or unordered_multimap) based on the key.
 
template<typename T >
bool byte_compare (const T &a, const T &b)
 

Enumeration Type Documentation

◆ AutoVacuumMode

SQLite auto-vacuum modes enumeration.

Enumerator
NONE 

No auto-vacuuming.

FULL 

Full auto-vacuuming.

INCREMENTAL 

Incremental auto-vacuuming.

Definition at line 40 of file Enums.hpp.

◆ JournalMode

enum class sqlite_containers::JournalMode
strong

SQLite journal modes enumeration.

Enumerator
DELETE_MODE 

Delete journal mode.

TRUNCATE 

Truncate journal mode.

PERSIST 

Persist journal mode.

MEMORY 

Memory journal mode.

WAL 

Write-ahead logging (WAL) mode.

OFF 

Off journal mode.

Definition at line 13 of file Enums.hpp.

◆ LockingMode

enum class sqlite_containers::LockingMode
strong

SQLite locking modes enumeration.

Enumerator
NORMAL 

Normal locking mode.

EXCLUSIVE 

Exclusive locking mode.

Definition at line 33 of file Enums.hpp.

◆ SynchronousMode

SQLite synchronous modes enumeration.

Enumerator
OFF 

Synchronous mode off.

NORMAL 

Normal synchronous mode.

FULL 

Full synchronous mode.

EXTRA 

Extra synchronous mode.

Definition at line 24 of file Enums.hpp.

◆ TempStore

enum class sqlite_containers::TempStore
strong

SQLite temporary storage modes enumeration.

Enumerator
DEFAULT 

Default temporary storage behavior.

FILE 

Temporary storage using a file.

MEMORY 

Temporary storage using memory.

Definition at line 48 of file Enums.hpp.

◆ TransactionMode

Defines SQLite transaction modes.

Enumerator
DEFERRED 

Waits to lock the database until a write operation is requested.

IMMEDIATE 

Locks the database for writing at the start, allowing only read operations by others.

EXCLUSIVE 

Locks the database for both reading and writing, blocking other transactions.

Definition at line 56 of file Enums.hpp.

Function Documentation

◆ add_value() [1/6]

template<template< class... > class ContainerT, typename KeyT , typename ValueT >
void sqlite_containers::add_value ( ContainerT< KeyT, ValueT > & container,
KeyT & key,
ValueT & value,
const size_t & value_count,
typename std::enable_if< std::is_same< ContainerT< KeyT, ValueT >, std::multimap< KeyT, ValueT > >::value||std::is_same< ContainerT< KeyT, ValueT >, std::unordered_multimap< KeyT, ValueT > >::value >::type * = 0 )
inline

Adds a key-value pair to a container (multimap or unordered_multimap).

Template Parameters
ContainerTThe type of container (multimap or unordered_multimap).
KeyTThe type of key.
ValueTThe type of value.
Parameters
containerThe container to which the key-value pair will be added.
keyThe key to add.
valueThe value to add.
value_countNumber of times to add the key-value pair (default is 0, meaning add once).

Definition at line 265 of file Utils.hpp.

◆ add_value() [2/6]

template<template< class... > class ContainerT, class T >
void sqlite_containers::add_value ( ContainerT< T > & container,
const T & value,
const size_t & value_count,
typename std::enable_if< std::is_same< ContainerT< T >, std::list< T > >::value||std::is_same< ContainerT< T >, std::vector< T > >::value||std::is_same< ContainerT< T >, std::deque< T > >::value >::type * = 0 )
inline

Adds a value to a container (list, vector, or deque).

Template Parameters
ContainerTThe type of container (list, vector, or deque).
TThe type of value to add.
Parameters
containerThe container to which the value will be added.
valueThe value to add.
value_countNumber of times to add the value (default is 0, meaning add once).

Definition at line 228 of file Utils.hpp.

◆ add_value() [3/6]

template<template< class... > class ContainerT, class T >
void sqlite_containers::add_value ( ContainerT< T > & container,
const T & value,
const size_t & value_count,
typename std::enable_if< std::is_same< ContainerT< T >, std::set< T > >::value||std::is_same< ContainerT< T >, std::multiset< T > >::value||std::is_same< ContainerT< T >, std::unordered_set< T > >::value||std::is_same< ContainerT< T >, std::unordered_multiset< T > >::value >::type * = 0 )
inline

Adds a value to a container (std::set).

Template Parameters
ContainerTThe type of container (std::set).
TThe type of value to add.
Parameters
containerThe container to which the value will be added.
valueThe value to add.
value_countNumber of times to add the value (default is 0, meaning add once).

Definition at line 245 of file Utils.hpp.

◆ add_value() [4/6]

template<template< class... > class ContainerT, class T >
void sqlite_containers::add_value ( ContainerT< T > & container,
const T & value,
const size_t & value_count = 0,
typename std::enable_if< std::is_same< ContainerT< T >, std::multiset< T > >::value||std::is_same< ContainerT< T >, std::unordered_multiset< T > >::value >::type * = 0 )
inline

Adds a value to a container (multiset or unordered_multiset).

Template Parameters
ContainerTThe type of container (multiset or unordered_multiset).
TThe type of value to add.
Parameters
containerThe container to which the value will be added.
valueThe value to add.
value_countNumber of times to add the value (default is 0, meaning add once).

Definition at line 198 of file Utils.hpp.

◆ add_value() [5/6]

template<template< class... > class ContainerT, class T >
void sqlite_containers::add_value ( ContainerT< T > & container,
T & value,
typename std::enable_if< std::is_same< ContainerT< T >, std::list< T > >::value||std::is_same< ContainerT< T >, std::vector< T > >::value||std::is_same< ContainerT< T >, std::deque< T > >::value >::type * = 0 )
inline

Adds a value to a container (list, vector, or deque).

Template Parameters
ContainerTThe type of container (list, vector, or deque).
TThe type of value to add.
Parameters
containerThe container to which the value will be added.
valueThe value to add.

Definition at line 213 of file Utils.hpp.

◆ add_value() [6/6]

template<template< class... > class ContainerT, class T >
void sqlite_containers::add_value ( ContainerT< T > & container,
T & value,
typename std::enable_if< std::is_same< ContainerT< T >, std::set< T > >::value||std::is_same< ContainerT< T >, std::unordered_set< T > >::value >::type * = 0 )
inline

Adds a value to a container (set or unordered_set).

Template Parameters
ContainerTThe type of container (set or unordered_set).
TThe type of value to add.
Parameters
containerThe container to which the value will be added.
valueThe value to add.

Definition at line 184 of file Utils.hpp.

◆ byte_compare()

template<typename T >
bool sqlite_containers::byte_compare ( const T & a,
const T & b )

Definition at line 339 of file Utils.hpp.

◆ execute() [1/4]

void sqlite_containers::execute ( sqlite3 * sqlite_db,
const char * query )
inline

Prepares and executes a SQLite statement given as a string.

Parameters
sqlite_dbPointer to the SQLite database.
queryThe SQL query to execute.
Exceptions
sqlite_exceptionif the database pointer is null, the request is empty, or if an error occurs during execution.

Definition at line 97 of file Utils.hpp.

◆ execute() [2/4]

void sqlite_containers::execute ( sqlite3 * sqlite_db,
const std::string & query )
inline

Prepares and executes a SQLite statement given as a string.

Parameters
sqlite_dbPointer to the SQLite database.
queryThe SQL query to execute.
Exceptions
sqlite_exceptionif the database pointer is null, the request is empty, or if an error occurs during execution.

Definition at line 120 of file Utils.hpp.

◆ execute() [3/4]

void sqlite_containers::execute ( sqlite3 * sqlite_db,
sqlite3_stmt * stmt )
inline

Executes a SQLite statement.

Parameters
sqlite_dbPointer to the SQLite database.
stmtPointer to the SQLite statement.
Exceptions
sqlite_exceptionif the database or statement is null, or if an error occurs during execution.

Definition at line 72 of file Utils.hpp.

◆ execute() [4/4]

void sqlite_containers::execute ( sqlite3_stmt * stmt)
inline

Executes a SQLite statement.

Parameters
stmtPointer to the SQLite statement.
Exceptions
sqlite_exceptionif statement is null, or if an error occurs during execution.

Definition at line 47 of file Utils.hpp.

◆ get_sqlite_type() [1/6]

template<typename T >
std::enable_if< std::is_trivially_copyable< typenameT::value_type >::value &&std::is_same< T, std::vector< typenameT::value_type > >::value, std::string >::type sqlite_containers::get_sqlite_type ( )
inline

Definition at line 162 of file Utils.hpp.

◆ get_sqlite_type() [2/6]

template<typename T >
std::enable_if< std::is_trivially_copyable< typenameT::value_type >::value &&std::is_same< T, std::deque< typenameT::value_type > >::value, std::string >::type sqlite_containers::get_sqlite_type ( )
inline

Definition at line 172 of file Utils.hpp.

◆ get_sqlite_type() [3/6]

template<typename T >
std::string sqlite_containers::get_sqlite_type ( typename std::enable_if< !std::is_integral< T >::value &&!std::is_floating_point< T >::value &&std::is_trivially_copyable< T >::value >::type * = 0)
inline

Definition at line 148 of file Utils.hpp.

◆ get_sqlite_type() [4/6]

template<typename T >
std::string sqlite_containers::get_sqlite_type ( typename std::enable_if< std::is_floating_point< T >::value >::type * = 0)
inline

Definition at line 136 of file Utils.hpp.

◆ get_sqlite_type() [5/6]

template<typename T >
std::string sqlite_containers::get_sqlite_type ( typename std::enable_if< std::is_integral< T >::value >::type * = 0)
inline

Gets the SQLite data type as a string for the given type.

Template Parameters
TThe type for which SQLite data type is queried.
Returns
The SQLite data type as a string.

Definition at line 130 of file Utils.hpp.

◆ get_sqlite_type() [6/6]

template<typename T >
std::string sqlite_containers::get_sqlite_type ( typename std::enable_if< std::is_same< T, std::string >::value >::type * = 0)
inline

Definition at line 142 of file Utils.hpp.

◆ get_values() [1/3]

template<template< class... > class ContainerT, template< class... > class ValueContainerT, typename KeyT , typename ValueT >
std::list< ValueT > sqlite_containers::get_values ( ContainerT< KeyT, ValueContainerT< ValueT > > & container,
const KeyT & key,
typename std::enable_if< std::is_same< ContainerT< KeyT, ValueT >, std::map< KeyT, ValueContainerT< ValueT > > >::value||std::is_same< ContainerT< KeyT, ValueT >, std::unordered_map< KeyT, ValueContainerT< ValueT > > >::value >::type * = 0 )
inline

Retrieves values from a container (map or unordered_map) based on the key.

Template Parameters
ContainerTThe type of container (map or unordered_map).
ValueContainerTThe type of container used for values (e.g., vector, list).
KeyTThe type of key.
ValueTThe type of value.
Parameters
containerThe container from which to retrieve values.
keyThe key to search for.
Returns
A list of values associated with the key (empty if key not found).

Definition at line 304 of file Utils.hpp.

◆ get_values() [2/3]

template<template< class... > class ContainerT, typename KeyT , typename ValueT >
std::list< ValueT > sqlite_containers::get_values ( ContainerT< KeyT, ValueT > & container,
const KeyT & key,
typename std::enable_if< std::is_same< ContainerT< KeyT, ValueT >, std::map< KeyT, ValueT > >::value||std::is_same< ContainerT< KeyT, ValueT >, std::unordered_map< KeyT, ValueT > >::value >::type * = 0 )
inline

Retrieves values from a container (map or unordered_map) based on the key.

Template Parameters
ContainerTThe type of container (map or unordered_map).
KeyTThe type of key.
ValueTThe type of value.
Parameters
containerThe container from which to retrieve values.
keyThe key to search for.
Returns
A list of values associated with the key (empty if key not found).

Definition at line 284 of file Utils.hpp.

◆ get_values() [3/3]

template<template< class... > class ContainerT, typename KeyT , typename ValueT >
std::list< ValueT > sqlite_containers::get_values ( ContainerT< KeyT, ValueT > & container,
const KeyT & key,
typename std::enable_if< std::is_same< ContainerT< KeyT, ValueT >, std::multimap< KeyT, ValueT > >::value||std::is_same< ContainerT< KeyT, ValueT >, std::unordered_multimap< KeyT, ValueT > >::value >::type * = 0 )
inline

Retrieves values from a container (multimap or unordered_multimap) based on the key.

Template Parameters
ContainerTThe type of container (multimap or unordered_multimap).
KeyTThe type of key.
ValueTThe type of value.
Parameters
containerThe container from which to retrieve values.
keyThe key to search for.
Returns
A list of values associated with the key (empty if key not found).

Definition at line 324 of file Utils.hpp.

◆ to_string() [1/5]

std::string sqlite_containers::to_string ( const AutoVacuumMode & mode)

Converts AutoVacuumMode enum to string representation.

Parameters
modeThe AutoVacuumMode enum value.
Returns
String representation of the AutoVacuumMode.

Definition at line 104 of file Enums.hpp.

◆ to_string() [2/5]

std::string sqlite_containers::to_string ( const JournalMode & mode)

Converts JournalMode enum to string representation.

Parameters
modeThe JournalMode enum value.
Returns
String representation of the JournalMode.

Definition at line 65 of file Enums.hpp.

◆ to_string() [3/5]

std::string sqlite_containers::to_string ( const LockingMode & mode)

Converts LockingMode enum to string representation.

Parameters
modeThe LockingMode enum value.
Returns
String representation of the LockingMode.

Definition at line 93 of file Enums.hpp.

◆ to_string() [4/5]

std::string sqlite_containers::to_string ( const SynchronousMode & mode)

Converts SynchronousMode enum to string representation.

Parameters
modeThe SynchronousMode enum value.
Returns
String representation of the SynchronousMode.

Definition at line 80 of file Enums.hpp.

◆ to_string() [5/5]

std::string sqlite_containers::to_string ( const TransactionMode & mode)

Converts TransactionMode enum to string representation.

Parameters
modeThe TransactionMode enum value.
Returns
String representation of the TransactionMode.

Definition at line 116 of file Enums.hpp.