-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRepo.hpp
86 lines (66 loc) · 1.92 KB
/
Repo.hpp
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef ___INANITY_OIL_REPO_HPP___
#define ___INANITY_OIL_REPO_HPP___
#include "oil.hpp"
#include "../inanity/data/data.hpp"
#include "../inanity/String.hpp"
BEGIN_INANITY
class MemoryFile;
END_INANITY
BEGIN_INANITY_DATA
class SqliteDb;
class SqliteStatement;
END_INANITY_DATA
BEGIN_INANITY_OIL
/// Base class for client and server repos.
class Repo : public Object
{
public:
/// Protocol magic value.
static const char protocolMagic[14];
/// Protocol version.
static const size_t protocolVersion;
/// Server repo application version.
/** Stored in SQLite db with pragma application_id. */
static const int serverRepoAppVersion;
/// Client repo application version.
/** Stored in SQLite db with pragma application_id. */
static const int clientRepoAppVersion;
//*** Default security constraints.
static const size_t defaultMaxKeySize;
static const size_t defaultMaxValueSize;
/// Maximum number key-value pairs in a push.
static const int defaultMaxPushKeysCount;
/// Maximum total size of values in a push.
static const size_t defaultMaxPushTotalSize;
/// Maximum number of key-value pairs in a pull response.
static const int defaultMaxPullKeysCount;
/// Maximum total size of values in a pull response.
static const size_t defaultMaxPullTotalSize;
/// Filename to create db in memory.
static const char* fileNameMemory;
/// Filename to create db in temporary file.
static const char* fileNameTemp;
protected:
/// SQLite database.
ptr<Data::SqliteDb> db;
//*** Temporaries.
/// Key buffer.
ptr<MemoryFile> keyBufferFile;
/// Value buffer.
ptr<MemoryFile> valueBufferFile;
void CheckAppVersion(int appVersion);
public: // for simplicity
//*** Security constraints.
size_t maxKeySize;
size_t maxValueSize;
int maxPushKeysCount;
size_t maxPushTotalSize;
int maxPullKeysCount;
size_t maxPullTotalSize;
public:
Repo(const char* fileName);
void Vacuum();
String IntegrityCheck() const;
};
END_INANITY_OIL
#endif