SQLite Containers
Loading...
Searching...
No Matches
sqlite_containers::KeyMultiValueDB< KeyT, ValueT > Class Template Referencefinal

Template class for managing key-value pairs in a SQLite database, where each key can map to multiple values. More...

#include <KeyMultiValueDB.hpp>

Inheritance diagram for sqlite_containers::KeyMultiValueDB< KeyT, ValueT >:
sqlite_containers::BaseDB

Public Member Functions

 KeyMultiValueDB ()
 Default constructor.
 
 KeyMultiValueDB (const Config &config)
 Constructor with configuration.
 
 ~KeyMultiValueDB () override final=default
 Destructor.
 
template<template< class... > class ContainerT>
KeyMultiValueDBoperator= (const ContainerT< KeyT, ValueT > &container)
 Assigns a container (e.g., std::multimap or std::unordered_multimap) to the database.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
KeyMultiValueDBoperator= (const ContainerT< KeyT, ValueContainerT< ValueT > > &container)
 Assigns a container where each key maps to a collection of values to the database.
 
template<template< class... > class ContainerT = std::multimap>
ContainerT< KeyT, ValueT > operator() ()
 Loads all key-value pairs from the database into a container.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
ContainerT< KeyT, ValueContainerT< ValueT > > operator() ()
 Loads all key-value pairs, where each key maps to a collection of values, from the database.
 
template<template< class... > class ContainerT>
void load (ContainerT< KeyT, ValueT > &container, const TransactionMode &mode)
 Loads data from the database into the container.
 
template<template< class... > class ContainerT>
void load (ContainerT< KeyT, ValueT > &container)
 Loads data from the database into the container.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void load (ContainerT< KeyT, ValueContainerT< ValueT > > &container, const TransactionMode &mode)
 Loads data from the database into the container.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void load (ContainerT< KeyT, ValueContainerT< ValueT > > &container)
 Loads data from the database into the container.
 
template<template< class... > class ContainerT>
ContainerT< KeyT, ValueT > retrieve_all (const TransactionMode &mode)
 Retrieves all key-value pairs from the database with a transaction.
 
template<template< class... > class ContainerT>
ContainerT< KeyT, ValueT > retrieve_all ()
 Retrieves all key-value pairs from the database.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
ContainerT< KeyT, ValueContainerT< ValueT > > retrieve_all (const TransactionMode &mode)
 Retrieves all key-value pairs from the database with a transaction.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
ContainerT< KeyT, ValueContainerT< ValueT > > retrieve_all ()
 Retrieves all key-value pairs from the database.
 
template<template< class... > class ContainerT>
void append (const ContainerT< KeyT, ValueT > &container, const TransactionMode &mode)
 Appends the content of the container to the database with a transaction.
 
template<template< class... > class ContainerT>
void append (const ContainerT< KeyT, ValueT > &container)
 Appends the content of the container to the database.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void append (const ContainerT< KeyT, ValueContainerT< ValueT > > &container, const TransactionMode &mode)
 Appends the content of the container to the database with a transaction.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void append (const ContainerT< KeyT, ValueContainerT< ValueT > > &container)
 Appends the content of the container to the database.
 
template<template< class... > class ContainerT>
void reconcile (const ContainerT< KeyT, ValueT > &container, const TransactionMode &mode)
 Reconciles the content of the container with the database with a transaction.
 
template<template< class... > class ContainerT>
void reconcile (const ContainerT< KeyT, ValueT > &container)
 Reconciles the content of the container with the database.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void reconcile (const ContainerT< KeyT, ValueContainerT< ValueT > > &container, const TransactionMode &mode)
 Reconciles the content of the container with the database with a transaction.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void reconcile (const ContainerT< KeyT, ValueContainerT< ValueT > > &container)
 Reconciles the content of the container with the database.
 
void insert (const KeyT &key, const ValueT &value, const TransactionMode &mode)
 Inserts a key-value pair into the database with a transaction.
 
void insert (const KeyT &key, const ValueT &value)
 Inserts a key-value pair into the database.
 
void insert (const std::pair< KeyT, ValueT > &pair, const TransactionMode &mode)
 Inserts a key-value pair into the database with a transaction.
 
void insert (const std::pair< KeyT, ValueT > &pair)
 Inserts a key-value pair into the database.
 
void set_value_count (const KeyT &key, const ValueT &value, const std::size_t &value_count)
 Sets the count of values associated with a specific key-value pair in the database.
 
void set_count (const KeyT &key, const ValueT &value, const std::size_t &value_count)
 Alias for set_value_count(). This method is an alias for set_value_count() and performs the same operation.
 
std::size_t get_value_count (const KeyT &key, const ValueT &value) const
 Retrieves the count of values associated with a specific key-value pair from the database. This method returns the number of associations between a given key and value in the database.
 
std::size_t count (const KeyT &key, const ValueT &value) const
 Alias for get_value_count(). This method is an alias for get_value_count() and performs the same operation.
 
template<template< class... > class ContainerT>
bool find (const KeyT &key, ContainerT< ValueT > &values)
 Finds values by key in the database.
 
std::size_t count () const
 Returns the number of elements in the database. This method returns the number of unique keys stored in the database, not the number of key-value pairs.
 
bool empty () const
 Checks if the database is empty. This method checks if there are any keys stored in the database.
 
void remove (const KeyT &key, const ValueT &value)
 Removes a specific key-value pair from the database.
 
void remove (const KeyT &key)
 Removes all values associated with a key from the database.
 
void clear (const TransactionMode &mode)
 Clears all key-value pairs from the database with a transaction.
 
void clear ()
 Clears all key-value pairs from the database.
 
- Public Member Functions inherited from sqlite_containers::BaseDB
 BaseDB ()=default
 Default constructor.
 
virtual ~BaseDB ()
 Destructor. Disconnects from the database if connected.
 
void set_config (const Config &config)
 Sets the configuration for the database.
 
Config get_config () const
 Gets the current configuration of the database.
 
void connect ()
 Connects to the database using the current configuration. Initializes a connection to the database by creating necessary directories, opening the database, creating tables, and setting up database parameters.
 
void connect (const Config &config)
 Connects to the database with the given configuration.
 
void disconnect ()
 Disconnects from the database.
 
void begin (const TransactionMode &mode=TransactionMode::DEFERRED)
 Begins a database transaction.
 
void commit ()
 Commits the current transaction.
 
void rollback ()
 Rolls back the current transaction.
 
template<typename Func >
void execute_in_transaction (Func operation, const TransactionMode &mode)
 Executes an operation inside a transaction.
 
virtual void process ()
 Processes asynchronous database requests (can be overridden).
 

Private Member Functions

void db_create_table (const Config &config) override final
 Creates the tables in the database. This method creates both the main and temporary tables for keys, values, and key-value pairs.
 
template<template< class... > class ContainerT>
void db_load (ContainerT< KeyT, ValueT > &container)
 Loads data from the database into the container.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void db_load (ContainerT< KeyT, ValueContainerT< ValueT > > &container)
 Loads data from the database into the container.
 
template<template< class... > class ContainerT>
void db_append (const ContainerT< KeyT, ValueT > &container)
 Appends the content of the container to the database.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void db_append (const ContainerT< KeyT, ValueContainerT< ValueT > > &container)
 Appends the content of the container to the database.
 
void db_insert (const KeyT &key, const ValueT &value)
 Inserts a key-value pair into the database.
 
template<template< class... > class ContainerT>
void db_reconcile (const ContainerT< KeyT, ValueT > &container)
 Reconciles the database with the provided container. This method compares the content of the provided container with the database, ensuring that all key-value pairs are synchronized. If keys or values do not exist in the database, they are inserted. If old data exists in the database, it is removed.
 
template<typename T >
std::vector< std::pair< T, int > >::iterator find_or_insert (std::vector< std::pair< T, int > > &vec, const T &value, typename std::enable_if< !std::is_integral< T >::value &&!std::is_floating_point< T >::value &&!std::is_same< T, std::string >::value &&!std::is_same< T, std::vector< char > >::value &&!std::is_same< T, std::vector< uint8_t > >::value &&std::is_trivially_copyable< T >::value >::type *=0)
 Finds or inserts a value into a sorted vector. This method finds a value in the vector, or inserts it if it is not present. It uses a specialized comparison depending on the type of value.
 
template<typename T >
std::vector< std::pair< T, int > >::iterator find_or_insert (std::vector< std::pair< T, int > > &vec, const T &value, typename std::enable_if< std::is_integral< T >::value||std::is_floating_point< T >::value||std::is_same< T, std::string >::value||std::is_same< T, std::vector< char > >::value||std::is_same< T, std::vector< uint8_t > >::value >::type *=0)
 Finds or inserts a value into a sorted vector. This method finds a value in the vector, or inserts it if it is not present. It uses a specialized comparison depending on the type of value.
 
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void db_reconcile (const ContainerT< KeyT, ValueContainerT< ValueT > > &container)
 Reconciles the database with the provided container, ensuring data integrity.
 
template<template< class... > class ContainerT>
bool db_find (const KeyT &key, ContainerT< ValueT > &container)
 Finds values by key in the database.
 
void db_set_value_count_key_value (const KeyT &key, const ValueT &value, const size_t &value_count)
 Sets the value count for a key-value pair in the database.
 
void db_remove_key_value (const KeyT &key, const ValueT &value)
 Removes a specific key-value pair from the database.
 
void db_remove_all_values (const KeyT &key)
 Removes all values associated with a key from the database.
 
std::size_t db_get_value_count_key_value (const KeyT &key, const ValueT &value) const
 Retrieves the count of a specific value associated with a key in the database.
 
std::size_t db_count_key () const
 Returns the number of elements in the database.
 
void db_clear ()
 Clears all key-value pairs from the database.
 
void db_insert_key (const KeyT &key)
 Inserts a key into the database.
 
int64_t db_get_key_id (const KeyT &key)
 Retrieves the ID of a key from the database.
 
void db_insert_value (const ValueT &value)
 Inserts a value into the database.
 
int64_t db_get_value_id (const ValueT &value)
 Retrieves the ID of a value from the database.
 
void db_insert_key_temp (const KeyT &key)
 Inserts a key into the temporary keys table.
 
void db_insert_value_temp (const ValueT &value)
 Inserts a value into the temporary values table.
 
void db_insert_key_value (const int64_t &key_id, const int64_t &value_id)
 Inserts a key-value pair into the key-value table.
 
std::size_t db_get_value_count (const int64_t &key_id, const int64_t &value_id)
 Retrieves the count of values associated with a specific key-value pair.
 
void db_set_value_count (const int64_t &key_id, const int64_t &value_id, const size_t &value_count)
 Sets the count of values associated with a specific key-value pair.
 
void db_purge_old_data ()
 Removes old keys and values that are no longer in the temporary tables.
 
void db_clear_temp_tables ()
 Clears the temporary keys and values tables.
 

Private Attributes

SqliteStmt m_stmt_load
 Statement for loading data from the database.
 
SqliteStmt m_stmt_insert_key
 Statement for inserting a key.
 
SqliteStmt m_stmt_insert_value
 Statement for inserting a value.
 
SqliteStmt m_stmt_insert_key_value
 Statement for inserting a key-value pair.
 
SqliteStmt m_stmt_get_key_id
 Statement for retrieving key ID.
 
SqliteStmt m_stmt_get_value_id
 Statement for retrieving value ID.
 
SqliteStmt m_stmt_get_value_count
 Statement for retrieving the count of a value.
 
SqliteStmt m_stmt_get_value_count_kv
 Statement for retrieving the count of a value by key-value pair.
 
SqliteStmt m_stmt_count_key
 Statement for counting the number of keys.
 
SqliteStmt m_stmt_insert_key_temp
 Statement for inserting keys into the temporary table.
 
SqliteStmt m_stmt_insert_value_temp
 Statement for inserting values into the temporary table.
 
SqliteStmt m_stmt_purge_keys
 Statement for purging old keys.
 
SqliteStmt m_stmt_purge_values
 Statement for purging old values.
 
SqliteStmt m_stmt_clear_keys_temp
 Statement for clearing the temporary keys table.
 
SqliteStmt m_stmt_clear_values_temp
 Statement for clearing the temporary values table.
 
SqliteStmt m_stmt_set_value_count
 Statement for setting value count for a key-value pair.
 
SqliteStmt m_stmt_set_value_count_kv
 Statement for setting value count by key-value pair.
 
SqliteStmt m_stmt_find
 Statement for finding values by key.
 
SqliteStmt m_stmt_remove_key_value
 Statement for removing a specific key-value pair.
 
SqliteStmt m_stmt_remove_all_values
 Statement for removing all values associated with a key.
 
SqliteStmt m_stmt_clear_keys
 Statement for clearing the keys table.
 
SqliteStmt m_stmt_clear_values
 Statement for clearing the values table.
 
SqliteStmt m_stmt_clear_key_values
 Statement for clearing the key-value pairs table.
 

Additional Inherited Members

- Protected Member Functions inherited from sqlite_containers::BaseDB
void db_begin (const TransactionMode &mode=TransactionMode::DEFERRED)
 Begins a transaction with the given mode.
 
void db_commit ()
 Commits the current transaction.
 
void db_rollback ()
 Rolls back the current transaction.
 
void db_handle_exception (std::exception_ptr ex, const std::vector< SqliteStmt * > &stmts, const std::string &message="Unknown error occurred.") const
 Handles an exception by resetting and clearing bindings of prepared SQL statements.
 
virtual void on_db_open ()
 Called after the database is opened. Can be overridden in derived classes.
 
virtual void on_db_close ()
 Called before the database is closed. Can be overridden in derived classes.
 
- Protected Attributes inherited from sqlite_containers::BaseDB
sqlite3 * m_sqlite_db = nullptr
 
std::mutex m_sqlite_mutex
 

Detailed Description

template<class KeyT, class ValueT>
class sqlite_containers::KeyMultiValueDB< KeyT, ValueT >

Template class for managing key-value pairs in a SQLite database, where each key can map to multiple values.

Template Parameters
KeyTType of the keys.
ValueTType of the values.

This class allows managing key-value pairs where each key can have multiple associated values. It supports operations on containers like std::multimap, std::unordered_multimap, or containers where keys map to collections of values, such as std::map<KeyT, std::vector<ValueT>>. The class provides methods for loading, appending, and reconciling key-value pairs with transactional integrity. It also supports custom containers for both keys and values, offering flexibility in data structures used for mapping. Temporary tables and bulk operations are employed for efficient reconciliation, with mechanisms to ensure data consistency between the database and in-memory structures.

Definition at line 22 of file KeyMultiValueDB.hpp.

Constructor & Destructor Documentation

◆ KeyMultiValueDB() [1/2]

template<class KeyT , class ValueT >
sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::KeyMultiValueDB ( )
inline

Default constructor.

Definition at line 26 of file KeyMultiValueDB.hpp.

◆ KeyMultiValueDB() [2/2]

template<class KeyT , class ValueT >
sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::KeyMultiValueDB ( const Config & config)
inline

Constructor with configuration.

Parameters
configConfiguration settings for the database.

Definition at line 30 of file KeyMultiValueDB.hpp.

◆ ~KeyMultiValueDB()

template<class KeyT , class ValueT >
sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::~KeyMultiValueDB ( )
finaloverridedefault

Destructor.

Member Function Documentation

◆ append() [1/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::append ( const ContainerT< KeyT, ValueContainerT< ValueT > > & container)
inline

Appends the content of the container to the database.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
ValueContainerTTemplate for the container type used for values (e.g., std::vector, std::set).
Parameters
containerContainer with content to be appended to the database.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 265 of file KeyMultiValueDB.hpp.

◆ append() [2/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::append ( const ContainerT< KeyT, ValueContainerT< ValueT > > & container,
const TransactionMode & mode )
inline

Appends the content of the container to the database with a transaction.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
ValueContainerTTemplate for the container type used for values (e.g., std::vector, std::set).
Parameters
containerContainer with content to be appended to the database.
modeTransaction mode.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 251 of file KeyMultiValueDB.hpp.

◆ append() [3/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::append ( const ContainerT< KeyT, ValueT > & container)
inline

Appends the content of the container to the database.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
Parameters
containerContainer with content to be appended to the database.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 238 of file KeyMultiValueDB.hpp.

◆ append() [4/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::append ( const ContainerT< KeyT, ValueT > & container,
const TransactionMode & mode )
inline

Appends the content of the container to the database with a transaction.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
Parameters
containerContainer with content to be appended to the database.
modeTransaction mode.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 225 of file KeyMultiValueDB.hpp.

◆ clear() [1/2]

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::clear ( )
inline

Clears all key-value pairs from the database.

Parameters
modeTransaction mode (defaults to the mode from the configuration).
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 476 of file KeyMultiValueDB.hpp.

◆ clear() [2/2]

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::clear ( const TransactionMode & mode)
inline

Clears all key-value pairs from the database with a transaction.

Parameters
modeTransaction mode (defaults to the mode from the configuration).
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 467 of file KeyMultiValueDB.hpp.

◆ count() [1/2]

template<class KeyT , class ValueT >
std::size_t sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::count ( ) const
inline

Returns the number of elements in the database. This method returns the number of unique keys stored in the database, not the number of key-value pairs.

Returns
The number of key-value pairs.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 434 of file KeyMultiValueDB.hpp.

◆ count() [2/2]

template<class KeyT , class ValueT >
std::size_t sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::count ( const KeyT & key,
const ValueT & value ) const
inline

Alias for get_value_count(). This method is an alias for get_value_count() and performs the same operation.

Parameters
keyThe key of the pair.
valueThe value of the pair.
Returns
The count of values associated with the key-value pair.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 413 of file KeyMultiValueDB.hpp.

◆ db_append() [1/2]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_append ( const ContainerT< KeyT, ValueContainerT< ValueT > > & container)
inlineprivate

Appends the content of the container to the database.

Template Parameters
ContainerTTemplate for the container type.
ValueContainerTTemplate for the container type used for values.
Parameters
containerContainer with content to be appended to the database.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 754 of file KeyMultiValueDB.hpp.

◆ db_append() [2/2]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_append ( const ContainerT< KeyT, ValueT > & container)
inlineprivate

Appends the content of the container to the database.

Template Parameters
ContainerTTemplate for the container type.
Parameters
containerContainer with content to be appended to the database.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 715 of file KeyMultiValueDB.hpp.

◆ db_clear()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_clear ( )
inlineprivate

Clears all key-value pairs from the database.

Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1159 of file KeyMultiValueDB.hpp.

◆ db_clear_temp_tables()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_clear_temp_tables ( )
inlineprivate

Clears the temporary keys and values tables.

Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1299 of file KeyMultiValueDB.hpp.

◆ db_count_key()

template<class KeyT , class ValueT >
std::size_t sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_count_key ( ) const
inlineprivate

Returns the number of elements in the database.

Returns
The number of key-value pairs in the database.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1125 of file KeyMultiValueDB.hpp.

◆ db_create_table()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_create_table ( const Config & config)
inlinefinaloverrideprivatevirtual

Creates the tables in the database. This method creates both the main and temporary tables for keys, values, and key-value pairs.

Parameters
configConfiguration settings for the database, such as table names.

Implements sqlite_containers::BaseDB.

Definition at line 526 of file KeyMultiValueDB.hpp.

◆ db_find()

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
bool sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_find ( const KeyT & key,
ContainerT< ValueT > & container )
inlineprivate

Finds values by key in the database.

Template Parameters
ContainerTTemplate for the container type.
Parameters
keyThe key to search for.
valuesThe container to store the values associated with the key.
Returns
True if the key was found, false otherwise.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1021 of file KeyMultiValueDB.hpp.

◆ db_get_key_id()

template<class KeyT , class ValueT >
int64_t sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_get_key_id ( const KeyT & key)
inlineprivate

Retrieves the ID of a key from the database.

Parameters
keyThe key whose ID is to be retrieved.
Returns
The ID of the key, or -1 if the key is not found.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1189 of file KeyMultiValueDB.hpp.

◆ db_get_value_count()

template<class KeyT , class ValueT >
std::size_t sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_get_value_count ( const int64_t & key_id,
const int64_t & value_id )
inlineprivate

Retrieves the count of values associated with a specific key-value pair.

Parameters
key_idThe ID of the key.
value_idThe ID of the value.
Returns
The count of values associated with the key-value pair.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1262 of file KeyMultiValueDB.hpp.

◆ db_get_value_count_key_value()

template<class KeyT , class ValueT >
std::size_t sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_get_value_count_key_value ( const KeyT & key,
const ValueT & value ) const
inlineprivate

Retrieves the count of a specific value associated with a key in the database.

Parameters
keyThe key.
valueThe value.
Returns
The count of the value associated with the key.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1102 of file KeyMultiValueDB.hpp.

◆ db_get_value_id()

template<class KeyT , class ValueT >
int64_t sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_get_value_id ( const ValueT & value)
inlineprivate

Retrieves the ID of a value from the database.

Parameters
valueThe value whose ID is to be retrieved.
Returns
The ID of the value, or -1 if the value is not found.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1214 of file KeyMultiValueDB.hpp.

◆ db_insert()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_insert ( const KeyT & key,
const ValueT & value )
inlineprivate

Inserts a key-value pair into the database.

Parameters
keyThe key to be inserted.
valueThe value to be inserted.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 794 of file KeyMultiValueDB.hpp.

◆ db_insert_key()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_insert_key ( const KeyT & key)
inlineprivate

Inserts a key into the database.

Parameters
keyThe key to be inserted.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1178 of file KeyMultiValueDB.hpp.

◆ db_insert_key_temp()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_insert_key_temp ( const KeyT & key)
inlineprivate

Inserts a key into the temporary keys table.

Parameters
keyThe key to be inserted into the temporary table.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1228 of file KeyMultiValueDB.hpp.

◆ db_insert_key_value()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_insert_key_value ( const int64_t & key_id,
const int64_t & value_id )
inlineprivate

Inserts a key-value pair into the key-value table.

Parameters
key_idThe ID of the key.
value_idThe ID of the value.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1249 of file KeyMultiValueDB.hpp.

◆ db_insert_value()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_insert_value ( const ValueT & value)
inlineprivate

Inserts a value into the database.

Parameters
valueThe value to be inserted.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1203 of file KeyMultiValueDB.hpp.

◆ db_insert_value_temp()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_insert_value_temp ( const ValueT & value)
inlineprivate

Inserts a value into the temporary values table.

Parameters
valueThe value to be inserted into the temporary table.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1238 of file KeyMultiValueDB.hpp.

◆ db_load() [1/2]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_load ( ContainerT< KeyT, ValueContainerT< ValueT > > & container)
inlineprivate

Loads data from the database into the container.

Template Parameters
ContainerTTemplate for the map container type.
ValueContainerTTemplate for the container type used for values.
Parameters
containerContainer to load the data into.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 676 of file KeyMultiValueDB.hpp.

◆ db_load() [2/2]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_load ( ContainerT< KeyT, ValueT > & container)
inlineprivate

Loads data from the database into the container.

Template Parameters
ContainerTTemplate for the container type.
Parameters
containerContainer to load the data into.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 636 of file KeyMultiValueDB.hpp.

◆ db_purge_old_data()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_purge_old_data ( )
inlineprivate

Removes old keys and values that are no longer in the temporary tables.

Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1290 of file KeyMultiValueDB.hpp.

◆ db_reconcile() [1/2]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_reconcile ( const ContainerT< KeyT, ValueContainerT< ValueT > > & container)
inlineprivate

Reconciles the database with the provided container, ensuring data integrity.

Template Parameters
ContainerTTemplate for the container type.
Parameters
containerContainer with content to reconcile with the database.
modeTransaction mode.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 948 of file KeyMultiValueDB.hpp.

◆ db_reconcile() [2/2]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_reconcile ( const ContainerT< KeyT, ValueT > & container)
inlineprivate

Reconciles the database with the provided container. This method compares the content of the provided container with the database, ensuring that all key-value pairs are synchronized. If keys or values do not exist in the database, they are inserted. If old data exists in the database, it is removed.

Template Parameters
ContainerTTemplate for the container type (e.g., std::map, std::unordered_map).
Parameters
containerThe container with key-value pairs to reconcile with the database.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 835 of file KeyMultiValueDB.hpp.

◆ db_remove_all_values()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_remove_all_values ( const KeyT & key)
inlineprivate

Removes all values associated with a key from the database.

Parameters
keyThe key of the pairs to be removed.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1083 of file KeyMultiValueDB.hpp.

◆ db_remove_key_value()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_remove_key_value ( const KeyT & key,
const ValueT & value )
inlineprivate

Removes a specific key-value pair from the database.

Parameters
keyThe key of the pair to be removed.
valueThe value of the pair to be removed.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1065 of file KeyMultiValueDB.hpp.

◆ db_set_value_count()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_set_value_count ( const int64_t & key_id,
const int64_t & value_id,
const size_t & value_count )
inlineprivate

Sets the count of values associated with a specific key-value pair.

Parameters
key_idThe ID of the key.
value_idThe ID of the value.
value_countThe count to be set.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1279 of file KeyMultiValueDB.hpp.

◆ db_set_value_count_key_value()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::db_set_value_count_key_value ( const KeyT & key,
const ValueT & value,
const size_t & value_count )
inlineprivate

Sets the value count for a key-value pair in the database.

Parameters
keyThe key.
valueThe value.
value_countThe count of the value associated with the key.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 1045 of file KeyMultiValueDB.hpp.

◆ empty()

template<class KeyT , class ValueT >
bool sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::empty ( ) const
inline

Checks if the database is empty. This method checks if there are any keys stored in the database.

Returns
True if the database is empty, false otherwise.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 443 of file KeyMultiValueDB.hpp.

◆ find()

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
bool sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::find ( const KeyT & key,
ContainerT< ValueT > & values )
inline

Finds values by key in the database.

Template Parameters
ContainerTTemplate for the container type.
Parameters
keyThe key to search for.
valuesThe container to store the values associated with the key.
Returns
True if the key was found, false otherwise.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 425 of file KeyMultiValueDB.hpp.

◆ find_or_insert() [1/2]

template<class KeyT , class ValueT >
template<typename T >
std::vector< std::pair< T, int > >::iterator sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::find_or_insert ( std::vector< std::pair< T, int > > & vec,
const T & value,
typename std::enable_if< !std::is_integral< T >::value &&!std::is_floating_point< T >::value &&!std::is_same< T, std::string >::value &&!std::is_same< T, std::vector< char > >::value &&!std::is_same< T, std::vector< uint8_t > >::value &&std::is_trivially_copyable< T >::value >::type * = 0 )
inlineprivate

Finds or inserts a value into a sorted vector. This method finds a value in the vector, or inserts it if it is not present. It uses a specialized comparison depending on the type of value.

Template Parameters
TThe type of the value.
Parameters
vecThe vector where the value will be searched or inserted.
valueThe value to search or insert.
Returns
Iterator to the position of the value in the vector.

Definition at line 899 of file KeyMultiValueDB.hpp.

◆ find_or_insert() [2/2]

template<class KeyT , class ValueT >
template<typename T >
std::vector< std::pair< T, int > >::iterator sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::find_or_insert ( std::vector< std::pair< T, int > > & vec,
const T & value,
typename std::enable_if< std::is_integral< T >::value||std::is_floating_point< T >::value||std::is_same< T, std::string >::value||std::is_same< T, std::vector< char > >::value||std::is_same< T, std::vector< uint8_t > >::value >::type * = 0 )
inlineprivate

Finds or inserts a value into a sorted vector. This method finds a value in the vector, or inserts it if it is not present. It uses a specialized comparison depending on the type of value.

Template Parameters
TThe type of the value.
Parameters
vecThe vector where the value will be searched or inserted.
valueThe value to search or insert.
Returns
Iterator to the position of the value in the vector.

Definition at line 926 of file KeyMultiValueDB.hpp.

◆ get_value_count()

template<class KeyT , class ValueT >
std::size_t sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::get_value_count ( const KeyT & key,
const ValueT & value ) const
inline

Retrieves the count of values associated with a specific key-value pair from the database. This method returns the number of associations between a given key and value in the database.

Parameters
keyThe key of the pair.
valueThe value of the pair.
Returns
The count of values associated with the key-value pair.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 402 of file KeyMultiValueDB.hpp.

◆ insert() [1/4]

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::insert ( const KeyT & key,
const ValueT & value )
inline

Inserts a key-value pair into the database.

Parameters
keyThe key to be inserted.
valueThe value to be inserted.
modeTransaction mode (defaults to the mode from the configuration).
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 341 of file KeyMultiValueDB.hpp.

◆ insert() [2/4]

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::insert ( const KeyT & key,
const ValueT & value,
const TransactionMode & mode )
inline

Inserts a key-value pair into the database with a transaction.

Parameters
keyThe key to be inserted.
valueThe value to be inserted.
modeTransaction mode (defaults to the mode from the configuration).
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 327 of file KeyMultiValueDB.hpp.

◆ insert() [3/4]

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::insert ( const std::pair< KeyT, ValueT > & pair)
inline

Inserts a key-value pair into the database.

Parameters
pairThe key-value pair to be inserted.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 363 of file KeyMultiValueDB.hpp.

◆ insert() [4/4]

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::insert ( const std::pair< KeyT, ValueT > & pair,
const TransactionMode & mode )
inline

Inserts a key-value pair into the database with a transaction.

Parameters
pairThe key-value pair to be inserted.
modeTransaction mode (defaults to the mode from the configuration).
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 352 of file KeyMultiValueDB.hpp.

◆ load() [1/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::load ( ContainerT< KeyT, ValueContainerT< ValueT > > & container)
inline

Loads data from the database into the container.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
ValueContainerTTemplate for the container type used for values (e.g., std::vector, std::set).
Parameters
containerContainer to load the data into.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 157 of file KeyMultiValueDB.hpp.

◆ load() [2/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::load ( ContainerT< KeyT, ValueContainerT< ValueT > > & container,
const TransactionMode & mode )
inline

Loads data from the database into the container.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
ValueContainerTTemplate for the container type used for values (e.g., std::vector, std::set).
Parameters
containerContainer to load the data into.
modeTransaction mode.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 143 of file KeyMultiValueDB.hpp.

◆ load() [3/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::load ( ContainerT< KeyT, ValueT > & container)
inline

Loads data from the database into the container.

Template Parameters
ContainerTTemplate for the container type (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap).
Parameters
containerContainer to load the data into.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 130 of file KeyMultiValueDB.hpp.

◆ load() [4/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::load ( ContainerT< KeyT, ValueT > & container,
const TransactionMode & mode )
inline

Loads data from the database into the container.

Template Parameters
ContainerTTemplate for the container type (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap).
Parameters
containerContainer to load the data into.
modeTransaction mode.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 117 of file KeyMultiValueDB.hpp.

◆ operator()() [1/2]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT = std::multimap>
ContainerT< KeyT, ValueT > sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::operator() ( )
inline

Loads all key-value pairs from the database into a container.

Template Parameters
ContainerTThe type of the container (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap).
Returns
A container populated with all key-value pairs from the database.
Exceptions
sqlite_exceptionif an SQLite error occurs.
Note
This method uses the default transaction mode from the database configuration.

Definition at line 80 of file KeyMultiValueDB.hpp.

◆ operator()() [2/2]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
ContainerT< KeyT, ValueContainerT< ValueT > > sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::operator() ( )
inline

Loads all key-value pairs, where each key maps to a collection of values, from the database.

Template Parameters
ContainerTTemplate for the outer container type (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap).
ValueContainerTTemplate for the inner container type used for values (e.g., std::vector, std::set).
Returns
A container populated with all key-value pairs, where each key maps to a collection of values.
Exceptions
sqlite_exceptionif an SQLite error occurs.
Note
This method uses the default transaction mode from the database configuration.

Definition at line 98 of file KeyMultiValueDB.hpp.

◆ operator=() [1/2]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
KeyMultiValueDB & sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::operator= ( const ContainerT< KeyT, ValueContainerT< ValueT > > & container)
inline

Assigns a container where each key maps to a collection of values to the database.

Template Parameters
ContainerTTemplate for the outer container type (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap).
ValueContainerTTemplate for the inner container type used for values (e.g., std::vector, std::set).
Parameters
containerThe container where each key maps to a collection of values.
Returns
Reference to this KeyMultiValueDB.
Exceptions
sqlite_exceptionif an SQLite error occurs.
Note
This method uses the default transaction mode from the database configuration.

Definition at line 64 of file KeyMultiValueDB.hpp.

◆ operator=() [2/2]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
KeyMultiValueDB & sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::operator= ( const ContainerT< KeyT, ValueT > & container)
inline

Assigns a container (e.g., std::multimap or std::unordered_multimap) to the database.

Template Parameters
ContainerTTemplate for the container type (e.g., std::map, std::unordered_map, std::multimap, std::unordered_multimap).
Parameters
containerThe container with key-value pairs to be inserted into the database.
Returns
Reference to this KeyMultiValueDB.
Exceptions
sqlite_exceptionif an SQLite error occur.
Note
This method uses the default transaction mode from the database configuration.

Definition at line 46 of file KeyMultiValueDB.hpp.

◆ reconcile() [1/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::reconcile ( const ContainerT< KeyT, ValueContainerT< ValueT > > & container)
inline

Reconciles the content of the container with the database.

Template Parameters
ContainerTTemplate for the container type (map or unordered_map).
ValueContainerTTemplate for the container type used for values.
Parameters
containerContainer with content to be reconciled with the database.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 317 of file KeyMultiValueDB.hpp.

◆ reconcile() [2/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::reconcile ( const ContainerT< KeyT, ValueContainerT< ValueT > > & container,
const TransactionMode & mode )
inline

Reconciles the content of the container with the database with a transaction.

Template Parameters
ContainerTTemplate for the container type (map or unordered_map).
ValueContainerTTemplate for the container type used for values.
Parameters
containerContainer with content to be reconciled with the database.
modeTransaction mode.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 303 of file KeyMultiValueDB.hpp.

◆ reconcile() [3/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::reconcile ( const ContainerT< KeyT, ValueT > & container)
inline

Reconciles the content of the container with the database.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
Parameters
containerContainer with content to be reconciled with the database.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 290 of file KeyMultiValueDB.hpp.

◆ reconcile() [4/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::reconcile ( const ContainerT< KeyT, ValueT > & container,
const TransactionMode & mode )
inline

Reconciles the content of the container with the database with a transaction.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
Parameters
containerContainer with content to be reconciled with the database.
modeTransaction mode.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 277 of file KeyMultiValueDB.hpp.

◆ remove() [1/2]

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::remove ( const KeyT & key)
inline

Removes all values associated with a key from the database.

Parameters
keyThe key of the pairs to be removed.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 459 of file KeyMultiValueDB.hpp.

◆ remove() [2/2]

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::remove ( const KeyT & key,
const ValueT & value )
inline

Removes a specific key-value pair from the database.

Parameters
keyThe key of the pair to be removed.
valueThe value of the pair to be removed.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 451 of file KeyMultiValueDB.hpp.

◆ retrieve_all() [1/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
ContainerT< KeyT, ValueT > sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::retrieve_all ( )
inline

Retrieves all key-value pairs from the database.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
Returns
A container with all key-value pairs.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 183 of file KeyMultiValueDB.hpp.

◆ retrieve_all() [2/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
ContainerT< KeyT, ValueContainerT< ValueT > > sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::retrieve_all ( )
inline

Retrieves all key-value pairs from the database.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
ValueContainerTTemplate for the container type used for values (e.g., std::vector, std::set).
Returns
A container with all key-value pairs.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 212 of file KeyMultiValueDB.hpp.

◆ retrieve_all() [3/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT>
ContainerT< KeyT, ValueT > sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::retrieve_all ( const TransactionMode & mode)
inline

Retrieves all key-value pairs from the database with a transaction.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
Parameters
modeTransaction mode.
Returns
A container with all key-value pairs.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 169 of file KeyMultiValueDB.hpp.

◆ retrieve_all() [4/4]

template<class KeyT , class ValueT >
template<template< class... > class ContainerT, template< class... > class ValueContainerT>
ContainerT< KeyT, ValueContainerT< ValueT > > sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::retrieve_all ( const TransactionMode & mode)
inline

Retrieves all key-value pairs from the database with a transaction.

Template Parameters
ContainerTTemplate for the container type (std::map, std::unordered_map, std::multimap or std::unordered_multimap).
ValueContainerTTemplate for the container type used for values (e.g., std::vector, std::set).
Parameters
modeTransaction mode.
Returns
A container with all key-value pairs.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 197 of file KeyMultiValueDB.hpp.

◆ set_count()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::set_count ( const KeyT & key,
const ValueT & value,
const std::size_t & value_count )
inline

Alias for set_value_count(). This method is an alias for set_value_count() and performs the same operation.

Parameters
keyThe key of the pair.
valueThe value of the pair.
value_countThe count to set.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 388 of file KeyMultiValueDB.hpp.

◆ set_value_count()

template<class KeyT , class ValueT >
void sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::set_value_count ( const KeyT & key,
const ValueT & value,
const std::size_t & value_count )
inline

Sets the count of values associated with a specific key-value pair in the database.

Parameters
keyThe key of the pair.
valueThe value of the pair.
value_countThe count to set.
Exceptions
sqlite_exceptionif an SQLite error occurs.

Definition at line 374 of file KeyMultiValueDB.hpp.

Member Data Documentation

◆ m_stmt_clear_key_values

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_clear_key_values
private

Statement for clearing the key-value pairs table.

Definition at line 521 of file KeyMultiValueDB.hpp.

◆ m_stmt_clear_keys

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_clear_keys
private

Statement for clearing the keys table.

Definition at line 519 of file KeyMultiValueDB.hpp.

◆ m_stmt_clear_keys_temp

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_clear_keys_temp
private

Statement for clearing the temporary keys table.

Definition at line 506 of file KeyMultiValueDB.hpp.

◆ m_stmt_clear_values

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_clear_values
private

Statement for clearing the values table.

Definition at line 520 of file KeyMultiValueDB.hpp.

◆ m_stmt_clear_values_temp

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_clear_values_temp
private

Statement for clearing the temporary values table.

Definition at line 507 of file KeyMultiValueDB.hpp.

◆ m_stmt_count_key

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_count_key
mutableprivate

Statement for counting the number of keys.

Definition at line 495 of file KeyMultiValueDB.hpp.

◆ m_stmt_find

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_find
private

Statement for finding values by key.

Definition at line 513 of file KeyMultiValueDB.hpp.

◆ m_stmt_get_key_id

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_get_key_id
private

Statement for retrieving key ID.

Definition at line 490 of file KeyMultiValueDB.hpp.

◆ m_stmt_get_value_count

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_get_value_count
private

Statement for retrieving the count of a value.

Definition at line 492 of file KeyMultiValueDB.hpp.

◆ m_stmt_get_value_count_kv

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_get_value_count_kv
mutableprivate

Statement for retrieving the count of a value by key-value pair.

Definition at line 493 of file KeyMultiValueDB.hpp.

◆ m_stmt_get_value_id

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_get_value_id
private

Statement for retrieving value ID.

Definition at line 491 of file KeyMultiValueDB.hpp.

◆ m_stmt_insert_key

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_insert_key
private

Statement for inserting a key.

Definition at line 486 of file KeyMultiValueDB.hpp.

◆ m_stmt_insert_key_temp

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_insert_key_temp
private

Statement for inserting keys into the temporary table.

Definition at line 498 of file KeyMultiValueDB.hpp.

◆ m_stmt_insert_key_value

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_insert_key_value
private

Statement for inserting a key-value pair.

Definition at line 488 of file KeyMultiValueDB.hpp.

◆ m_stmt_insert_value

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_insert_value
private

Statement for inserting a value.

Definition at line 487 of file KeyMultiValueDB.hpp.

◆ m_stmt_insert_value_temp

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_insert_value_temp
private

Statement for inserting values into the temporary table.

Definition at line 499 of file KeyMultiValueDB.hpp.

◆ m_stmt_load

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_load
private

Statement for loading data from the database.

Definition at line 484 of file KeyMultiValueDB.hpp.

◆ m_stmt_purge_keys

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_purge_keys
private

Statement for purging old keys.

Definition at line 502 of file KeyMultiValueDB.hpp.

◆ m_stmt_purge_values

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_purge_values
private

Statement for purging old values.

Definition at line 503 of file KeyMultiValueDB.hpp.

◆ m_stmt_remove_all_values

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_remove_all_values
private

Statement for removing all values associated with a key.

Definition at line 517 of file KeyMultiValueDB.hpp.

◆ m_stmt_remove_key_value

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_remove_key_value
private

Statement for removing a specific key-value pair.

Definition at line 516 of file KeyMultiValueDB.hpp.

◆ m_stmt_set_value_count

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_set_value_count
private

Statement for setting value count for a key-value pair.

Definition at line 510 of file KeyMultiValueDB.hpp.

◆ m_stmt_set_value_count_kv

template<class KeyT , class ValueT >
SqliteStmt sqlite_containers::KeyMultiValueDB< KeyT, ValueT >::m_stmt_set_value_count_kv
private

Statement for setting value count by key-value pair.

Definition at line 511 of file KeyMultiValueDB.hpp.


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