-
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathCustomString.hpp
More file actions
37 lines (29 loc) · 892 Bytes
/
CustomString.hpp
File metadata and controls
37 lines (29 loc) · 892 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
//
// CustomString.hpp
// NitroTest
//
// Created by Marc Rousavy on 28.08.25.
//
#pragma once
#include <NitroModules/JSIConverter.hpp>
#include <string>
namespace margelo::nitro::test {
// for demonstration, let's just do a struct that holds a string.
struct CustomString {
std::string string;
};
}; // namespace margelo::nitro::test
namespace margelo::nitro {
template <>
struct JSIConverter<test::CustomString> final {
static inline test::CustomString fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
return test::CustomString(arg.asString(runtime).utf8(runtime));
}
static inline jsi::Value toJSI(jsi::Runtime& runtime, const test::CustomString& arg) {
return jsi::String::createFromUtf8(runtime, arg.string);
}
static inline bool canConvert(jsi::Runtime&, const jsi::Value& value) {
return value.isString();
}
};
} // namespace margelo::nitro