SQLiteXX  0.1.0
 All Classes Namespaces Files Functions Enumerations Enumerator
Backup.h
Go to the documentation of this file.
1 
3 #ifndef __SQLITEXX_SQLITE_BACKUP_H__
4 #define __SQLITEXX_SQLITE_BACKUP_H__
5 
6 #include "DBConnection.h"
7 
8 #include <sqlite3.h>
9 
10 #include <memory>
11 
12 namespace sqlite
13 {
20  class backup
21  {
22  public:
32  backup(
33  const dbconnection& source,
34  const dbconnection& destination,
35  const std::string& sourceName = "main",
36  const std::string& destinationName = "main");
37 
47  bool step(const int pages = -1);
48 
56  int total_page_count() noexcept;
57 
65  int remaining_page_count() noexcept;
66 
69  sqlite3_backup* handle() noexcept;
70 
71  private:
72  using backup_handle = std::unique_ptr<sqlite3_backup, decltype(&sqlite3_backup_finish)>;
73  backup_handle m_handle;
74 
75  const dbconnection* m_destination = nullptr;
76 
77  backup(const backup& other) = delete;
78  backup& operator=(backup& other) = delete;
79  };
80 
81  void save(const dbconnection& source, const std::string& filename);
82 }
83 
84 #endif
Used to aid in the process of backing up a database.
Definition: Backup.h:20
backup(const dbconnection &source, const dbconnection &destination, const std::string &sourceName="main", const std::string &destinationName="main")
Construct a backup object.
Definition: Backup.cpp:14
int remaining_page_count() noexcept
Returns the number of pages still to be backed up.
Definition: Backup.cpp:51
int total_page_count() noexcept
Returns the total number of pages in the source database.
Definition: Backup.cpp:46
bool step(const int pages=-1)
Will copy a specified number of pages to the destination database.
Definition: Backup.cpp:34
sqlite3_backup * handle() noexcept
Returns the pointer to the underlying sqlite3_backup object.
Definition: Backup.cpp:56
Class that represents a connection to a database.
Definition: DBConnection.h:24