-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathbackup.cpp
More file actions
42 lines (32 loc) · 753 Bytes
/
backup.cpp
File metadata and controls
42 lines (32 loc) · 753 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// (c) 2013 Stephan Hohe
#include "backup.hpp"
#include "error.hpp"
#include <sqlite3.h>
namespace sqxx {
backup::backup(connection &dest, const char *ddb, connection &source, const char *sdb)
: handle(sqlite3_backup_init(source.raw(), sdb, dest.raw(), ddb)) {
if (!handle)
throw recent_error(dest.raw());
}
backup::~backup() {
if (handle) {
sqlite3_backup_finish(handle);
}
}
bool backup::step(int pages) {
int rv;
rv = sqlite3_backup_step(handle, pages);
if (rv == SQLITE_OK)
return true;
else if (rv == SQLITE_DONE)
return false;
else
throw static_error(rv);
}
int backup::remaining() {
return sqlite3_backup_remaining(handle);
}
int backup::pagecount() {
return sqlite3_backup_pagecount(handle);
}
} // namespace sqxx