SQLite Containers
Loading...
Searching...
No Matches
Utils.hpp File Reference

Utility functions for working with SQLite in sqlite_containers. More...

#include <sqlite3.h>
#include <stdexcept>
#include <string>
#include <thread>
#include <chrono>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cstring>
#include <type_traits>

Go to the source code of this file.

Classes

class  sqlite_containers::sqlite_exception
 Exception class for SQLite errors. More...
 

Namespaces

namespace  sqlite_containers
 

Macros

#define SQLITE_CONTAINERS_BUSY_RETRY_DELAY_MS   50
 

Functions

void sqlite_containers::execute (sqlite3_stmt *stmt)
 Executes a SQLite statement.
 
void sqlite_containers::execute (sqlite3 *sqlite_db, sqlite3_stmt *stmt)
 Executes a SQLite statement.
 
void sqlite_containers::execute (sqlite3 *sqlite_db, const char *query)
 Prepares and executes a SQLite statement given as a string.
 
void sqlite_containers::execute (sqlite3 *sqlite_db, const std::string &query)
 Prepares and executes a SQLite statement given as a string.
 
template<typename T >
std::string sqlite_containers::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 sqlite_containers::get_sqlite_type (typename std::enable_if< std::is_floating_point< T >::value >::type *=0)
 
template<typename T >
std::string sqlite_containers::get_sqlite_type (typename std::enable_if< std::is_same< T, std::string >::value >::type *=0)
 
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)
 
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 ()
 
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 ()
 
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)
 Adds a value to a container (set or unordered_set).
 
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)
 Adds a value to a container (multiset or unordered_multiset).
 
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)
 Adds a value to a container (list, vector, or deque).
 
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)
 Adds a value to a container (list, vector, or deque).
 
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)
 Adds a value to a container (std::set).
 
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)
 Adds a key-value pair to a container (multimap or unordered_multimap).
 
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)
 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 > 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)
 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 > 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)
 Retrieves values from a container (multimap or unordered_multimap) based on the key.
 
template<typename T >
bool sqlite_containers::byte_compare (const T &a, const T &b)
 

Detailed Description

Utility functions for working with SQLite in sqlite_containers.

Definition in file Utils.hpp.

Macro Definition Documentation

◆ SQLITE_CONTAINERS_BUSY_RETRY_DELAY_MS

#define SQLITE_CONTAINERS_BUSY_RETRY_DELAY_MS   50

Definition at line 22 of file Utils.hpp.