Skip to content

Commit 5d66167

Browse files
committed
fix: missing nitrogen file
1 parent a24d524 commit 5d66167

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

package/cpp/types.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#pragma once
22

3+
#include <string>
4+
#include <NitroModules/ArrayBuffer.hpp>
35
#include "SQLiteQueryColumnMetadata.hpp"
46
#include "ColumnType.hpp"
5-
#include <NitroModules/ArrayBuffer.hpp>
6-
#include <string>
7+
#include "NativeSQLiteNullValue.hpp"
78

89
using namespace margelo::nitro;
910
using namespace margelo::nitro::rnnitrosqlite;
1011

1112
namespace margelo::rnnitrosqlite {
1213

1314
// using SQLiteValue = std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>, std::monostate>;
14-
using SQLiteValue = std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>>;
15+
using SQLiteValue = std::variant<std::string, double, int64_t, bool, std::shared_ptr<ArrayBuffer>, NativeSqliteNullValue>;
1516
using SQLiteQueryParams = std::vector<SQLiteValue>;
1617
using SQLiteQueryResultRow = std::unordered_map<std::string, SQLiteValue>;
1718
using SQLiteQueryResults = std::vector<SQLiteQueryResultRow>;
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
///
2+
/// NativeSQLiteNullValue.hpp
3+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4+
/// https://github.com/mrousavy/nitro
5+
/// Copyright © 2025 Marc Rousavy @ Margelo
6+
///
7+
8+
#pragma once
9+
10+
#if __has_include(<NitroModules/JSIConverter.hpp>)
11+
#include <NitroModules/JSIConverter.hpp>
12+
#else
13+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14+
#endif
15+
#if __has_include(<NitroModules/NitroDefines.hpp>)
16+
#include <NitroModules/NitroDefines.hpp>
17+
#else
18+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19+
#endif
20+
21+
22+
23+
24+
25+
namespace margelo::nitro::rnnitrosqlite {
26+
27+
/**
28+
* A struct which can be represented as a JavaScript object (NativeSQLiteNullValue).
29+
*/
30+
struct NativeSQLiteNullValue {
31+
public:
32+
bool isNull SWIFT_PRIVATE;
33+
34+
public:
35+
explicit NativeSQLiteNullValue(bool isNull): isNull(isNull) {}
36+
};
37+
38+
} // namespace margelo::nitro::rnnitrosqlite
39+
40+
namespace margelo::nitro {
41+
42+
using namespace margelo::nitro::rnnitrosqlite;
43+
44+
// C++ NativeSQLiteNullValue <> JS NativeSQLiteNullValue (object)
45+
template <>
46+
struct JSIConverter<NativeSQLiteNullValue> {
47+
static inline NativeSQLiteNullValue fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
48+
jsi::Object obj = arg.asObject(runtime);
49+
return NativeSQLiteNullValue(
50+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isNull"))
51+
);
52+
}
53+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const NativeSQLiteNullValue& arg) {
54+
jsi::Object obj(runtime);
55+
obj.setProperty(runtime, "isNull", JSIConverter<bool>::toJSI(runtime, arg.isNull));
56+
return obj;
57+
}
58+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
59+
if (!value.isObject()) {
60+
return false;
61+
}
62+
jsi::Object obj = value.getObject(runtime);
63+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isNull"))) return false;
64+
return true;
65+
}
66+
};
67+
68+
} // namespace margelo::nitro

0 commit comments

Comments
 (0)