Enigma  3.2.0
A Simple, Reliable and Efficient Encryption Tool
Database Class Referencefinal

#include <Database.hpp>

Public Types

enum class  OrderBy : byte { ID , Title , DateTime , Size }
 
enum class  Order : byte { Ascending , Descending }
 

Static Public Member Functions

static void initialize ()
 
static void shutdown ()
 
static std::int64_t addEncryption (const std::unique_ptr< Encryption > &e)
 
static std::int64_t addCipherChunk (const std::unique_ptr< CipherChunk > &cc)
 
static std::unique_ptr< EncryptiongetEncryption (const std::int64_t ide)
 
static std::unique_ptr< CipherChunkgetCipherChunk (const std::int64_t ide)
 
static void getCipherChunks (const std::int64_t ide, const std::function< bool(std::unique_ptr< CipherChunk > &&cc)> &callback)
 
static std::vector< std::unique_ptr< Encryption > > getAllEncryptions (const OrderBy order_by=OrderBy::ID, const Order order=Order::Descending)
 
static bool deleteEncryption (const std::int64_t ide)
 
static bool deleteAllEncryptions ()
 
static std::vector< std::unique_ptr< Encryption > > searchEncryptionsByTitle (const std::string &qtitle, OrderBy order_by=OrderBy::ID, Order order=Order::Descending)
 
static const std::unique_ptr< SQLite::Database > & getStorage () noexcept
 
static void Vacuum () noexcept
 
static void Export (const fs::path &filename)
 
static void Import (const fs::path &filename)
 

Friends

const char * operator* (OrderBy order_by)
 
std::ostream & operator<< (std::ostream &os, const OrderBy order_by) noexcept
 
const char * operator* (Order order)
 
std::ostream & operator<< (std::ostream &os, const Order order) noexcept
 

Detailed Description

Enigma SQLite database to store and retrieve encryption records User can export and import Database file to clouds or drives Database file will store Encrypted Text and Encrypted Files ciphers and other info

Definition at line 23 of file Database.hpp.

Member Enumeration Documentation

◆ Order

enum Database::Order : byte
strong

Encryption Table order column

Enumerator
Ascending 
Descending 

Definition at line 73 of file Database.hpp.

◆ OrderBy

enum Database::OrderBy : byte
strong

Encryption Table order by column

Enumerator
ID 
Title 
DateTime 
Size 

Definition at line 29 of file Database.hpp.

Member Function Documentation

◆ addCipherChunk()

static std::int64_t Database::addCipherChunk ( const std::unique_ptr< CipherChunk > &  cc)
static

Add CipherChunk record to database table

Parameters
ideEncryption id this CipherChunk belongs to
Returns
inserted CipherChunk id std::int64_t>=0 on success, -1 on failure

◆ addEncryption()

static std::int64_t Database::addEncryption ( const std::unique_ptr< Encryption > &  e)
static

Add Encryption record to database table

Returns
inserted encryption id std::int64_t>=0 on success, -1 on failure

◆ deleteAllEncryptions()

static bool Database::deleteAllEncryptions ( )
static

Delete all Encryption records by id, returns true if successfully deleted Note: all associated CipherChunks with all encryptions will be automatically deleted due ON DELETE CASCADE

◆ deleteEncryption()

static bool Database::deleteEncryption ( const std::int64_t  ide)
static

Delete Encryption record by id, returns true if successfully deleted Note: all associated CipherChunks with this encryption will be automatically deleted due ON DELETE CASCADE

◆ Export()

static void Database::Export ( const fs::path &  filename)
static

◆ getAllEncryptions()

static std::vector<std::unique_ptr<Encryption> > Database::getAllEncryptions ( const OrderBy  order_by = OrderBy::ID,
const Order  order = Order::Descending 
)
static

Get a CipherChunk by Encryption id

◆ getCipherChunk()

static std::unique_ptr<CipherChunk> Database::getCipherChunk ( const std::int64_t  ide)
static

Get a CipherChunk by Encryption id Used for small text encryptions

◆ getCipherChunks()

static void Database::getCipherChunks ( const std::int64_t  ide,
const std::function< bool(std::unique_ptr< CipherChunk > &&cc)> &  callback 
)
static

Get CipherChunks iteratively by Encryption id, ordered by offset from 0 -> LAST Used for large files encryptions

◆ getEncryption()

static std::unique_ptr<Encryption> Database::getEncryption ( const std::int64_t  ide)
static

Get an Encryption by id

◆ getStorage()

static const std::unique_ptr<SQLite::Database>& Database::getStorage ( )
inlinestaticnoexcept

Returns SQLite database connection instance

Definition at line 152 of file Database.hpp.

◆ Import()

static void Database::Import ( const fs::path &  filename)
static

◆ initialize()

static void Database::initialize ( )
static

Initializes SQLite database connection

◆ searchEncryptionsByTitle()

static std::vector<std::unique_ptr<Encryption> > Database::searchEncryptionsByTitle ( const std::string &  qtitle,
OrderBy  order_by = OrderBy::ID,
Order  order = Order::Descending 
)
static

Search Encryptions by title using keyword LIKE QUERY%

◆ shutdown()

static void Database::shutdown ( )
static

Shuts down SQLite connection

◆ Vacuum()

static void Database::Vacuum ( )
staticnoexcept

Cleans up allocated disk space for deleted data, blob...

When you insert or delete data from the tables, the indexes and tables become fragmented, especially for the database that has a high number of inserts, updates, and deletes.

Note
https://www.sqlitetutorial.net/sqlite-vacuum/

Friends And Related Function Documentation

◆ operator* [1/2]

const char* operator* ( Order  order)
friend

To help stringify enum Order

Definition at line 80 of file Database.hpp.

◆ operator* [2/2]

const char* operator* ( OrderBy  order_by)
friend

To help stringify enum OrderBy

Definition at line 38 of file Database.hpp.

◆ operator<< [1/2]

std::ostream& operator<< ( std::ostream &  os,
const Order  order 
)
friend

Definition at line 93 of file Database.hpp.

◆ operator<< [2/2]

std::ostream& operator<< ( std::ostream &  os,
const OrderBy  order_by 
)
friend

Definition at line 52 of file Database.hpp.


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