-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathteensy41SQLite.cpp
112 lines (90 loc) · 2.08 KB
/
teensy41SQLite.cpp
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include "teensy41SQLite.hpp"
int T41SQLite::begin(FS* io_filesystem)
{
m_filesystem = io_filesystem;
return sqlite3_initialize();
}
int T41SQLite::end()
{
int result = sqlite3_shutdown();
m_filesystem = nullptr;
return result;
}
FS* T41SQLite::getFilesystem()
{
return m_filesystem;
}
void T41SQLite::setDBDirFullPath(const String &in_dbDirFullpath)
{
m_dbDirFullpath = in_dbDirFullpath;
}
const String &T41SQLite::getDBDirFullPath() const
{
return m_dbDirFullpath;
}
int T41SQLite::setLogCallback(LogCallback in_callback, void* in_forUseInCallback)
{
return sqlite3_config(SQLITE_CONFIG_LOG, in_callback, in_forUseInCallback);
}
void T41SQLite::resetSectorSize()
{
m_sectorSize = 0;
}
void T41SQLite::setSectorSize(int in_size)
{
m_sectorSize = in_size;
}
int T41SQLite::getSectorSize() const
{
return m_sectorSize;
}
/*
** This methods overwrites the values set with setDeviceCharacteristics!
** It returns true if a valid sector is given (set by call to setSectorSize).
** Otherwise it retruns false.
*/
bool T41SQLite::assumeSingleSectorWriteIsAtomic()
{
switch (m_sectorSize)
{
case 512 * 1:
m_deviceCharacteristics = SQLITE_IOCAP_ATOMIC512;
break;
case 512 * 2:
m_deviceCharacteristics = SQLITE_IOCAP_ATOMIC1K;
break;
case 512 * 4:
m_deviceCharacteristics = SQLITE_IOCAP_ATOMIC2K;
break;
case 512 * 8:
m_deviceCharacteristics = SQLITE_IOCAP_ATOMIC4K;
break;
case 512 * 16:
m_deviceCharacteristics = SQLITE_IOCAP_ATOMIC8K;
break;
case 512 * 32:
m_deviceCharacteristics = SQLITE_IOCAP_ATOMIC16K;
break;
case 512 * 64:
m_deviceCharacteristics = SQLITE_IOCAP_ATOMIC32K;
break;
case 512 * 128:
m_deviceCharacteristics = SQLITE_IOCAP_ATOMIC64K;
break;
default:
return false;
}
return true;
}
void T41SQLite::resetDeviceCharacteristics()
{
m_deviceCharacteristics = 0;
}
void T41SQLite::setDeviceCharacteristics(int in_ioCap)
{
m_deviceCharacteristics = in_ioCap;
}
int T41SQLite::getDeviceCharacteristics() const
{
return m_deviceCharacteristics;
}