-
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathtypes.hpp
More file actions
43 lines (36 loc) · 1.33 KB
/
types.hpp
File metadata and controls
43 lines (36 loc) · 1.33 KB
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
#pragma once
#include "ColumnType.hpp"
#include "NitroSQLiteQueryColumnMetadata.hpp"
#include <NitroModules/ArrayBuffer.hpp>
#include <string>
using namespace margelo::nitro;
using namespace margelo::nitro::rnnitrosqlite;
namespace margelo::rnnitrosqlite {
using SQLiteValue = std::variant<nitro::NullType, bool, std::shared_ptr<ArrayBuffer>, std::string, double>;
using SQLiteQueryParams = std::vector<SQLiteValue>;
using SQLiteQueryResultRow = std::unordered_map<std::string, SQLiteValue>;
using SQLiteQueryResults = std::vector<SQLiteQueryResultRow>;
using SQLiteQueryTableMetadata = std::unordered_map<std::string, NitroSQLiteQueryColumnMetadata>;
struct SQLiteOperationResult {
int rowsAffected;
int commands = 0;
};
// constexpr function that maps SQLiteColumnType to string literals
inline ColumnType mapSQLiteTypeToColumnType(const char* type) {
if (type == NULL) {
return ColumnType::NULL_VALUE;
} else if (strcmp(type, "BOOLEAN")) {
return ColumnType::BOOLEAN;
} else if (strcmp(type, "FLOAT")) {
return ColumnType::NUMBER;
} else if (strcmp(type, "INTEGER")) {
return ColumnType::INT64;
} else if (strcmp(type, "TEXT")) {
return ColumnType::TEXT;
} else if (strcmp(type, "BLOB")) {
return ColumnType::ARRAY_BUFFER;
} else {
return ColumnType::NULL_VALUE;
}
}
} // namespace margelo::rnnitrosqlite