14        os << ms.
a << 
" " << ms.
b;
 
 
   34template <
typename SetType>
 
   35void print_set(
const SetType& set, 
const std::string& header) {
 
   36    std::cout << header << std::endl;
 
   37    for (
const auto& key : set) {
 
   38        std::cout << key << std::endl;
 
   40    std::cout << std::endl;
 
 
   44template <
typename ListType>
 
   45void print_list(
const ListType& list, 
const std::string& header) {
 
   46    std::cout << header << std::endl;
 
   47    for (
const auto& key : list) {
 
   48        std::cout << key << std::endl;
 
   50    std::cout << std::endl;
 
 
   57        config.
db_path = 
"example-set-struct.db";
 
   67        std::set<MyStruct> keys = {
 
   79        std::set<MyStruct> retrieved_keys_set = key_db.
retrieve_all<std::set>();
 
   80        print_set(retrieved_keys_set, 
"Keys in database after append:");
 
   84        std::list<MyStruct> retrieved_keys_list = key_db.
retrieve_all<std::list>();
 
   85        print_list(retrieved_keys_list, 
"Keys in database after insert:");
 
   88        if (key_db.
find({60, 1.0})) {
 
   89            std::cout << 
"Key {60, 1.0} found in the database." << std::endl;
 
   91            std::cout << 
"Key {60, 1.0} not found in the database." << std::endl;
 
   95        if (key_db.
find({100, 8.0})) {
 
   96            std::cout << 
"Key {100, 8.0} found in the database." << std::endl;
 
   98            std::cout << 
"Key {100, 8.0} not found in the database." << std::endl;
 
  105        std::vector<MyStruct> retrieved_keys_vector = key_db.
retrieve_all<std::vector>();
 
  106        print_list(retrieved_keys_vector, 
"Keys in database after removing key {30, 4.0}:");
 
  109        std::cout << 
"Number of keys in the database: " << key_db.
count() << std::endl;
 
  110        std::cout << 
"Is the database empty? " << (key_db.
empty() ? 
"Yes" : 
"No") << std::endl;
 
  113        std::cerr << 
"SQLite error: " << e.what() << std::endl;
 
  114    } 
catch (
const std::exception &e) {
 
  115        std::cerr << 
"Error: " << e.what() << std::endl;
 
 
Declaration of the KeyDB class for managing keys in a SQLite database.
 
void connect()
Connects to the database using the current configuration. Initializes a connection to the database by...
 
Configuration class for SQLite database settings.
 
std::string db_path
Path to the SQLite database file.
 
Template class for managing keys in a SQLite database.
 
std::size_t count() const
Returns the number of keys in the database.
 
bool empty() const
Checks if the database is empty (no keys present).
 
bool find(const KeyT &key)
Finds if a key exists in the database.
 
ContainerT< KeyT > retrieve_all()
Retrieves all keys from the database.
 
void append(const ContainerT< KeyT > &container)
Appends the content of the container to the database.
 
void insert(const KeyT &key)
Inserts a key into the database.
 
void clear()
Clears all keys from the database.
 
void remove(const KeyT &key)
Removes a key from the database.
 
Exception class for SQLite errors.
 
void print_set(const SetType &set, const std::string &header)
 
void print_list(const ListType &list, const std::string &header)
 
friend std::istream & operator>>(std::istream &is, MyStruct &ms)
 
bool operator<(const MyStruct &other) const
 
friend std::ostream & operator<<(std::ostream &os, const MyStruct &ms)