react-native-nitro-geolocation 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/GetCurrentPosition.kt +4 -4
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocation.kt +642 -50
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/NitroGeolocationCompat.kt +81 -0
- package/android/src/main/java/com/margelo/nitro/nitrogeolocation/WatchPosition.kt +4 -4
- package/ios/LocationManager.swift +113 -128
- package/ios/NitroGeolocation.swift +546 -61
- package/ios/NitroGeolocationCompat.swift +109 -0
- package/nitrogen/generated/android/c++/JAuthorizationLevel.hpp +61 -0
- package/nitrogen/generated/android/c++/JAuthorizationLevelInternal.hpp +3 -4
- package/nitrogen/generated/android/c++/JFunc_void.hpp +2 -1
- package/nitrogen/generated/android/c++/JFunc_void_GeolocationError.hpp +2 -1
- package/nitrogen/generated/android/c++/JFunc_void_GeolocationResponse.hpp +6 -1
- package/nitrogen/generated/android/c++/JFunc_void_LocationError.hpp +78 -0
- package/nitrogen/generated/android/c++/JGeolocationCoordinates.hpp +25 -17
- package/nitrogen/generated/android/c++/JGeolocationError.hpp +5 -1
- package/nitrogen/generated/android/c++/JGeolocationOptions.hpp +5 -1
- package/nitrogen/generated/android/c++/JGeolocationResponse.hpp +9 -1
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.cpp +109 -0
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationCompatSpec.hpp +70 -0
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.cpp +98 -42
- package/nitrogen/generated/android/c++/JHybridNitroGeolocationSpec.hpp +7 -5
- package/nitrogen/generated/android/c++/JLocationError.hpp +61 -0
- package/nitrogen/generated/android/c++/JLocationProvider.hpp +61 -0
- package/nitrogen/generated/android/c++/JLocationProviderInternal.hpp +3 -4
- package/nitrogen/generated/android/c++/JLocationRequestOptions.hpp +81 -0
- package/nitrogen/generated/android/c++/JModernGeolocationConfiguration.hpp +73 -0
- package/nitrogen/generated/android/c++/JNullableDouble.cpp +26 -0
- package/nitrogen/generated/android/c++/JNullableDouble.hpp +69 -0
- package/nitrogen/generated/android/c++/JPermissionStatus.hpp +64 -0
- package/nitrogen/generated/android/c++/JRNConfigurationInternal.hpp +5 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevel.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/AuthorizationLevelInternal.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void.kt +0 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationError.kt +0 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_GeolocationResponse.kt +0 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/Func_void_LocationError.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationCoordinates.kt +34 -25
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationError.kt +27 -18
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationOptions.kt +33 -24
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/GeolocationResponse.kt +18 -9
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationCompatSpec.kt +92 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/HybridNitroGeolocationSpec.kt +17 -17
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationError.kt +41 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProvider.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationProviderInternal.kt +2 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/LocationRequestOptions.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/ModernGeolocationConfiguration.kt +47 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/NullableDouble.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/PermissionStatus.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrogeolocation/RNConfigurationInternal.kt +24 -15
- package/nitrogen/generated/android/nitrogeolocation+autolinking.cmake +3 -0
- package/nitrogen/generated/android/nitrogeolocationOnLoad.cpp +14 -2
- package/nitrogen/generated/ios/NitroGeolocation+autolinking.rb +1 -1
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.cpp +55 -13
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Bridge.hpp +325 -68
- package/nitrogen/generated/ios/NitroGeolocation-Swift-Cxx-Umbrella.hpp +26 -0
- package/nitrogen/generated/ios/NitroGeolocationAutolinking.mm +8 -0
- package/nitrogen/generated/ios/NitroGeolocationAutolinking.swift +15 -0
- package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroGeolocationCompatSpecSwift.hpp +130 -0
- package/nitrogen/generated/ios/c++/HybridNitroGeolocationSpecSwift.hpp +47 -26
- package/nitrogen/generated/ios/swift/AuthorizationLevel.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_GeolocationError.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_GeolocationResponse.swift +1 -1
- package/nitrogen/generated/ios/swift/Func_void_LocationError.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_PermissionStatus.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/GeolocationCoordinates.swift +132 -93
- package/nitrogen/generated/ios/swift/GeolocationError.swift +11 -40
- package/nitrogen/generated/ios/swift/GeolocationOptions.swift +29 -98
- package/nitrogen/generated/ios/swift/GeolocationResponse.swift +5 -16
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec.swift +61 -0
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationCompatSpec_cxx.swift +244 -0
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec.swift +13 -5
- package/nitrogen/generated/ios/swift/HybridNitroGeolocationSpec_cxx.swift +66 -64
- package/nitrogen/generated/ios/swift/LocationError.swift +35 -0
- package/nitrogen/generated/ios/swift/LocationProvider.swift +44 -0
- package/nitrogen/generated/ios/swift/LocationRequestOptions.swift +116 -0
- package/nitrogen/generated/ios/swift/ModernGeolocationConfiguration.swift +83 -0
- package/nitrogen/generated/ios/swift/NullableDouble.swift +18 -0
- package/nitrogen/generated/ios/swift/PermissionStatus.swift +48 -0
- package/nitrogen/generated/ios/swift/RNConfigurationInternal.swift +16 -50
- package/nitrogen/generated/shared/c++/AuthorizationLevel.hpp +80 -0
- package/nitrogen/generated/shared/c++/GeolocationCoordinates.hpp +45 -27
- package/nitrogen/generated/shared/c++/GeolocationError.hpp +32 -16
- package/nitrogen/generated/shared/c++/GeolocationOptions.hpp +38 -22
- package/nitrogen/generated/shared/c++/GeolocationResponse.hpp +23 -7
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationCompatSpec.hpp +79 -0
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.cpp +4 -3
- package/nitrogen/generated/shared/c++/HybridNitroGeolocationSpec.hpp +22 -16
- package/nitrogen/generated/shared/c++/LocationError.hpp +87 -0
- package/nitrogen/generated/shared/c++/LocationProvider.hpp +80 -0
- package/nitrogen/generated/shared/c++/LocationRequestOptions.hpp +107 -0
- package/nitrogen/generated/shared/c++/ModernGeolocationConfiguration.hpp +100 -0
- package/nitrogen/generated/shared/c++/PermissionStatus.hpp +84 -0
- package/nitrogen/generated/shared/c++/RNConfigurationInternal.hpp +29 -13
- package/package.json +16 -7
- package/src/GeolocationClient.ts +116 -0
- package/src/NitroGeolocation.nitro.ts +177 -30
- package/src/NitroGeolocationCompat.nitro.ts +41 -0
- package/src/NitroGeolocationModule.ts +6 -0
- package/src/compat/clearWatch.ts +9 -0
- package/src/{getCurrentPosition.ts → compat/getCurrentPosition.ts} +7 -3
- package/src/compat/index.tsx +34 -0
- package/src/compat/requestAuthorization.ts +9 -0
- package/src/{setRNConfiguration.ts → compat/setRNConfiguration.ts} +6 -4
- package/src/{stopObserving.ts → compat/stopObserving.ts} +4 -2
- package/src/{watchPosition.ts → compat/watchPosition.ts} +7 -6
- package/src/components/GeolocationProvider.tsx +91 -0
- package/src/components/index.ts +13 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useCheckPermission.ts +46 -0
- package/src/hooks/useGetCurrentPosition.ts +44 -0
- package/src/hooks/useRequestPermission.ts +38 -0
- package/src/hooks/useWatchPosition.ts +127 -0
- package/src/index.tsx +72 -27
- package/src/types.ts +32 -4
- package/src/utils/cache.ts +25 -0
- package/src/utils/config.ts +93 -0
- package/src/utils/errors.ts +82 -0
- package/src/utils/index.ts +27 -0
- package/src/utils/provider.ts +61 -0
- package/src/utils/quality.ts +98 -0
- package/README.md +0 -318
- package/src/clearWatch.ts +0 -13
- package/src/requestAuthorization.ts +0 -9
|
@@ -7,41 +7,51 @@
|
|
|
7
7
|
|
|
8
8
|
#include "JHybridNitroGeolocationSpec.hpp"
|
|
9
9
|
|
|
10
|
-
// Forward declaration of `
|
|
11
|
-
namespace margelo::nitro::nitrogeolocation {
|
|
12
|
-
// Forward declaration of `AuthorizationLevelInternal` to properly resolve imports.
|
|
13
|
-
namespace margelo::nitro::nitrogeolocation { enum class AuthorizationLevelInternal; }
|
|
14
|
-
// Forward declaration of `LocationProviderInternal` to properly resolve imports.
|
|
15
|
-
namespace margelo::nitro::nitrogeolocation { enum class LocationProviderInternal; }
|
|
16
|
-
// Forward declaration of `GeolocationError` to properly resolve imports.
|
|
17
|
-
namespace margelo::nitro::nitrogeolocation { struct GeolocationError; }
|
|
10
|
+
// Forward declaration of `PermissionStatus` to properly resolve imports.
|
|
11
|
+
namespace margelo::nitro::nitrogeolocation { enum class PermissionStatus; }
|
|
18
12
|
// Forward declaration of `GeolocationResponse` to properly resolve imports.
|
|
19
13
|
namespace margelo::nitro::nitrogeolocation { struct GeolocationResponse; }
|
|
20
14
|
// Forward declaration of `GeolocationCoordinates` to properly resolve imports.
|
|
21
15
|
namespace margelo::nitro::nitrogeolocation { struct GeolocationCoordinates; }
|
|
22
|
-
// Forward declaration of `
|
|
23
|
-
namespace margelo::nitro::nitrogeolocation { struct
|
|
16
|
+
// Forward declaration of `ModernGeolocationConfiguration` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::nitrogeolocation { struct ModernGeolocationConfiguration; }
|
|
18
|
+
// Forward declaration of `AuthorizationLevel` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::nitrogeolocation { enum class AuthorizationLevel; }
|
|
20
|
+
// Forward declaration of `LocationProvider` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::nitrogeolocation { enum class LocationProvider; }
|
|
22
|
+
// Forward declaration of `LocationRequestOptions` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::nitrogeolocation { struct LocationRequestOptions; }
|
|
24
|
+
// Forward declaration of `LocationError` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::nitrogeolocation { struct LocationError; }
|
|
24
26
|
|
|
25
|
-
#include "
|
|
26
|
-
#include
|
|
27
|
-
#include
|
|
28
|
-
#include
|
|
29
|
-
#include "JAuthorizationLevelInternal.hpp"
|
|
30
|
-
#include "LocationProviderInternal.hpp"
|
|
31
|
-
#include "JLocationProviderInternal.hpp"
|
|
32
|
-
#include <functional>
|
|
33
|
-
#include "JFunc_void.hpp"
|
|
34
|
-
#include "GeolocationError.hpp"
|
|
35
|
-
#include "JFunc_void_GeolocationError.hpp"
|
|
36
|
-
#include "JGeolocationError.hpp"
|
|
37
|
-
#include <string>
|
|
27
|
+
#include "PermissionStatus.hpp"
|
|
28
|
+
#include <NitroModules/Promise.hpp>
|
|
29
|
+
#include <NitroModules/JPromise.hpp>
|
|
30
|
+
#include "JPermissionStatus.hpp"
|
|
38
31
|
#include "GeolocationResponse.hpp"
|
|
39
|
-
#include "JFunc_void_GeolocationResponse.hpp"
|
|
40
32
|
#include "JGeolocationResponse.hpp"
|
|
41
33
|
#include "GeolocationCoordinates.hpp"
|
|
42
34
|
#include "JGeolocationCoordinates.hpp"
|
|
43
|
-
#include
|
|
44
|
-
#include
|
|
35
|
+
#include <NitroModules/Null.hpp>
|
|
36
|
+
#include <variant>
|
|
37
|
+
#include <optional>
|
|
38
|
+
#include "JNullableDouble.hpp"
|
|
39
|
+
#include <NitroModules/JNull.hpp>
|
|
40
|
+
#include <string>
|
|
41
|
+
#include "ModernGeolocationConfiguration.hpp"
|
|
42
|
+
#include "JModernGeolocationConfiguration.hpp"
|
|
43
|
+
#include "AuthorizationLevel.hpp"
|
|
44
|
+
#include "JAuthorizationLevel.hpp"
|
|
45
|
+
#include "LocationProvider.hpp"
|
|
46
|
+
#include "JLocationProvider.hpp"
|
|
47
|
+
#include "LocationRequestOptions.hpp"
|
|
48
|
+
#include "JLocationRequestOptions.hpp"
|
|
49
|
+
#include <functional>
|
|
50
|
+
#include "JFunc_void_GeolocationResponse.hpp"
|
|
51
|
+
#include <NitroModules/JNICallable.hpp>
|
|
52
|
+
#include "LocationError.hpp"
|
|
53
|
+
#include "JFunc_void_LocationError.hpp"
|
|
54
|
+
#include "JLocationError.hpp"
|
|
45
55
|
|
|
46
56
|
namespace margelo::nitro::nitrogeolocation {
|
|
47
57
|
|
|
@@ -65,30 +75,76 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
65
75
|
method(_javaPart);
|
|
66
76
|
}
|
|
67
77
|
|
|
78
|
+
std::string JHybridNitroGeolocationSpec::toString() {
|
|
79
|
+
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
80
|
+
auto javaString = method(_javaPart);
|
|
81
|
+
return javaString->toStdString();
|
|
82
|
+
}
|
|
83
|
+
|
|
68
84
|
// Properties
|
|
69
85
|
|
|
70
86
|
|
|
71
87
|
// Methods
|
|
72
|
-
void JHybridNitroGeolocationSpec::
|
|
73
|
-
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<
|
|
74
|
-
method(_javaPart,
|
|
88
|
+
void JHybridNitroGeolocationSpec::setConfiguration(const ModernGeolocationConfiguration& config) {
|
|
89
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JModernGeolocationConfiguration> /* config */)>("setConfiguration");
|
|
90
|
+
method(_javaPart, JModernGeolocationConfiguration::fromCpp(config));
|
|
91
|
+
}
|
|
92
|
+
std::shared_ptr<Promise<PermissionStatus>> JHybridNitroGeolocationSpec::checkPermission() {
|
|
93
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("checkPermission");
|
|
94
|
+
auto __result = method(_javaPart);
|
|
95
|
+
return [&]() {
|
|
96
|
+
auto __promise = Promise<PermissionStatus>::create();
|
|
97
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
98
|
+
auto __result = jni::static_ref_cast<JPermissionStatus>(__boxedResult);
|
|
99
|
+
__promise->resolve(__result->toCpp());
|
|
100
|
+
});
|
|
101
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
102
|
+
jni::JniException __jniError(__throwable);
|
|
103
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
104
|
+
});
|
|
105
|
+
return __promise;
|
|
106
|
+
}();
|
|
75
107
|
}
|
|
76
|
-
|
|
77
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
78
|
-
|
|
108
|
+
std::shared_ptr<Promise<PermissionStatus>> JHybridNitroGeolocationSpec::requestPermission() {
|
|
109
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("requestPermission");
|
|
110
|
+
auto __result = method(_javaPart);
|
|
111
|
+
return [&]() {
|
|
112
|
+
auto __promise = Promise<PermissionStatus>::create();
|
|
113
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
114
|
+
auto __result = jni::static_ref_cast<JPermissionStatus>(__boxedResult);
|
|
115
|
+
__promise->resolve(__result->toCpp());
|
|
116
|
+
});
|
|
117
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
118
|
+
jni::JniException __jniError(__throwable);
|
|
119
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
120
|
+
});
|
|
121
|
+
return __promise;
|
|
122
|
+
}();
|
|
79
123
|
}
|
|
80
|
-
|
|
81
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
82
|
-
|
|
124
|
+
std::shared_ptr<Promise<GeolocationResponse>> JHybridNitroGeolocationSpec::getCurrentPosition(const std::optional<LocationRequestOptions>& options) {
|
|
125
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<JLocationRequestOptions> /* options */)>("getCurrentPosition");
|
|
126
|
+
auto __result = method(_javaPart, options.has_value() ? JLocationRequestOptions::fromCpp(options.value()) : nullptr);
|
|
127
|
+
return [&]() {
|
|
128
|
+
auto __promise = Promise<GeolocationResponse>::create();
|
|
129
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
130
|
+
auto __result = jni::static_ref_cast<JGeolocationResponse>(__boxedResult);
|
|
131
|
+
__promise->resolve(__result->toCpp());
|
|
132
|
+
});
|
|
133
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
134
|
+
jni::JniException __jniError(__throwable);
|
|
135
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
136
|
+
});
|
|
137
|
+
return __promise;
|
|
138
|
+
}();
|
|
83
139
|
}
|
|
84
|
-
|
|
85
|
-
static const auto method = javaClassStatic()->getMethod<
|
|
86
|
-
auto __result = method(_javaPart, JFunc_void_GeolocationResponse_cxx::fromCpp(success), error.has_value() ?
|
|
87
|
-
return __result;
|
|
140
|
+
std::string JHybridNitroGeolocationSpec::watchPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const LocationError& /* error */)>>& error, const std::optional<LocationRequestOptions>& options) {
|
|
141
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<jni::JString>(jni::alias_ref<JFunc_void_GeolocationResponse::javaobject> /* success */, jni::alias_ref<JFunc_void_LocationError::javaobject> /* error */, jni::alias_ref<JLocationRequestOptions> /* options */)>("watchPosition_cxx");
|
|
142
|
+
auto __result = method(_javaPart, JFunc_void_GeolocationResponse_cxx::fromCpp(success), error.has_value() ? JFunc_void_LocationError_cxx::fromCpp(error.value()) : nullptr, options.has_value() ? JLocationRequestOptions::fromCpp(options.value()) : nullptr);
|
|
143
|
+
return __result->toStdString();
|
|
88
144
|
}
|
|
89
|
-
void JHybridNitroGeolocationSpec::
|
|
90
|
-
static const auto method = javaClassStatic()->getMethod<void(
|
|
91
|
-
method(_javaPart,
|
|
145
|
+
void JHybridNitroGeolocationSpec::unwatch(const std::string& token) {
|
|
146
|
+
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JString> /* token */)>("unwatch");
|
|
147
|
+
method(_javaPart, jni::make_jstring(token));
|
|
92
148
|
}
|
|
93
149
|
void JHybridNitroGeolocationSpec::stopObserving() {
|
|
94
150
|
static const auto method = javaClassStatic()->getMethod<void()>("stopObserving");
|
|
@@ -41,6 +41,7 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
41
41
|
public:
|
|
42
42
|
size_t getExternalMemorySize() noexcept override;
|
|
43
43
|
void dispose() noexcept override;
|
|
44
|
+
std::string toString() override;
|
|
44
45
|
|
|
45
46
|
public:
|
|
46
47
|
inline const jni::global_ref<JHybridNitroGeolocationSpec::javaobject>& getJavaPart() const noexcept {
|
|
@@ -53,11 +54,12 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
53
54
|
|
|
54
55
|
public:
|
|
55
56
|
// Methods
|
|
56
|
-
void
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
void
|
|
57
|
+
void setConfiguration(const ModernGeolocationConfiguration& config) override;
|
|
58
|
+
std::shared_ptr<Promise<PermissionStatus>> checkPermission() override;
|
|
59
|
+
std::shared_ptr<Promise<PermissionStatus>> requestPermission() override;
|
|
60
|
+
std::shared_ptr<Promise<GeolocationResponse>> getCurrentPosition(const std::optional<LocationRequestOptions>& options) override;
|
|
61
|
+
std::string watchPosition(const std::function<void(const GeolocationResponse& /* position */)>& success, const std::optional<std::function<void(const LocationError& /* error */)>>& error, const std::optional<LocationRequestOptions>& options) override;
|
|
62
|
+
void unwatch(const std::string& token) override;
|
|
61
63
|
void stopObserving() override;
|
|
62
64
|
|
|
63
65
|
private:
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JLocationError.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
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "LocationError.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "LocationError" and the the Kotlin data class "LocationError".
|
|
21
|
+
*/
|
|
22
|
+
struct JLocationError final: public jni::JavaClass<JLocationError> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/LocationError;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct LocationError by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
LocationError toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldCode = clazz->getField<double>("code");
|
|
35
|
+
double code = this->getFieldValue(fieldCode);
|
|
36
|
+
static const auto fieldMessage = clazz->getField<jni::JString>("message");
|
|
37
|
+
jni::local_ref<jni::JString> message = this->getFieldValue(fieldMessage);
|
|
38
|
+
return LocationError(
|
|
39
|
+
code,
|
|
40
|
+
message->toStdString()
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public:
|
|
45
|
+
/**
|
|
46
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
47
|
+
*/
|
|
48
|
+
[[maybe_unused]]
|
|
49
|
+
static jni::local_ref<JLocationError::javaobject> fromCpp(const LocationError& value) {
|
|
50
|
+
using JSignature = JLocationError(double, jni::alias_ref<jni::JString>);
|
|
51
|
+
static const auto clazz = javaClassStatic();
|
|
52
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
53
|
+
return create(
|
|
54
|
+
clazz,
|
|
55
|
+
value.code,
|
|
56
|
+
jni::make_jstring(value.message)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JLocationProvider.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
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "LocationProvider.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "LocationProvider" and the the Kotlin enum "LocationProvider".
|
|
19
|
+
*/
|
|
20
|
+
struct JLocationProvider final: public jni::JavaClass<JLocationProvider> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/LocationProvider;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum LocationProvider.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
LocationProvider toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<LocationProvider>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JLocationProvider> fromCpp(LocationProvider value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case LocationProvider::AUTO:
|
|
46
|
+
static const auto fieldAUTO = clazz->getStaticField<JLocationProvider>("AUTO");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldAUTO);
|
|
48
|
+
case LocationProvider::PLAYSERVICES:
|
|
49
|
+
static const auto fieldPLAYSERVICES = clazz->getStaticField<JLocationProvider>("PLAYSERVICES");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldPLAYSERVICES);
|
|
51
|
+
case LocationProvider::ANDROID_PLATFORM:
|
|
52
|
+
static const auto fieldANDROID_PLATFORM = clazz->getStaticField<JLocationProvider>("ANDROID_PLATFORM");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldANDROID_PLATFORM);
|
|
54
|
+
default:
|
|
55
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
56
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -41,16 +41,15 @@ namespace margelo::nitro::nitrogeolocation {
|
|
|
41
41
|
[[maybe_unused]]
|
|
42
42
|
static jni::alias_ref<JLocationProviderInternal> fromCpp(LocationProviderInternal value) {
|
|
43
43
|
static const auto clazz = javaClassStatic();
|
|
44
|
-
static const auto fieldAUTO = clazz->getStaticField<JLocationProviderInternal>("AUTO");
|
|
45
|
-
static const auto fieldPLAYSERVICES = clazz->getStaticField<JLocationProviderInternal>("PLAYSERVICES");
|
|
46
|
-
static const auto fieldANDROID_PLATFORM = clazz->getStaticField<JLocationProviderInternal>("ANDROID_PLATFORM");
|
|
47
|
-
|
|
48
44
|
switch (value) {
|
|
49
45
|
case LocationProviderInternal::AUTO:
|
|
46
|
+
static const auto fieldAUTO = clazz->getStaticField<JLocationProviderInternal>("AUTO");
|
|
50
47
|
return clazz->getStaticFieldValue(fieldAUTO);
|
|
51
48
|
case LocationProviderInternal::PLAYSERVICES:
|
|
49
|
+
static const auto fieldPLAYSERVICES = clazz->getStaticField<JLocationProviderInternal>("PLAYSERVICES");
|
|
52
50
|
return clazz->getStaticFieldValue(fieldPLAYSERVICES);
|
|
53
51
|
case LocationProviderInternal::ANDROID_PLATFORM:
|
|
52
|
+
static const auto fieldANDROID_PLATFORM = clazz->getStaticField<JLocationProviderInternal>("ANDROID_PLATFORM");
|
|
54
53
|
return clazz->getStaticFieldValue(fieldANDROID_PLATFORM);
|
|
55
54
|
default:
|
|
56
55
|
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JLocationRequestOptions.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
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "LocationRequestOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "LocationRequestOptions" and the the Kotlin data class "LocationRequestOptions".
|
|
21
|
+
*/
|
|
22
|
+
struct JLocationRequestOptions final: public jni::JavaClass<JLocationRequestOptions> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/LocationRequestOptions;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct LocationRequestOptions by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
LocationRequestOptions toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldTimeout = clazz->getField<jni::JDouble>("timeout");
|
|
35
|
+
jni::local_ref<jni::JDouble> timeout = this->getFieldValue(fieldTimeout);
|
|
36
|
+
static const auto fieldMaximumAge = clazz->getField<jni::JDouble>("maximumAge");
|
|
37
|
+
jni::local_ref<jni::JDouble> maximumAge = this->getFieldValue(fieldMaximumAge);
|
|
38
|
+
static const auto fieldEnableHighAccuracy = clazz->getField<jni::JBoolean>("enableHighAccuracy");
|
|
39
|
+
jni::local_ref<jni::JBoolean> enableHighAccuracy = this->getFieldValue(fieldEnableHighAccuracy);
|
|
40
|
+
static const auto fieldInterval = clazz->getField<jni::JDouble>("interval");
|
|
41
|
+
jni::local_ref<jni::JDouble> interval = this->getFieldValue(fieldInterval);
|
|
42
|
+
static const auto fieldFastestInterval = clazz->getField<jni::JDouble>("fastestInterval");
|
|
43
|
+
jni::local_ref<jni::JDouble> fastestInterval = this->getFieldValue(fieldFastestInterval);
|
|
44
|
+
static const auto fieldDistanceFilter = clazz->getField<jni::JDouble>("distanceFilter");
|
|
45
|
+
jni::local_ref<jni::JDouble> distanceFilter = this->getFieldValue(fieldDistanceFilter);
|
|
46
|
+
static const auto fieldUseSignificantChanges = clazz->getField<jni::JBoolean>("useSignificantChanges");
|
|
47
|
+
jni::local_ref<jni::JBoolean> useSignificantChanges = this->getFieldValue(fieldUseSignificantChanges);
|
|
48
|
+
return LocationRequestOptions(
|
|
49
|
+
timeout != nullptr ? std::make_optional(timeout->value()) : std::nullopt,
|
|
50
|
+
maximumAge != nullptr ? std::make_optional(maximumAge->value()) : std::nullopt,
|
|
51
|
+
enableHighAccuracy != nullptr ? std::make_optional(static_cast<bool>(enableHighAccuracy->value())) : std::nullopt,
|
|
52
|
+
interval != nullptr ? std::make_optional(interval->value()) : std::nullopt,
|
|
53
|
+
fastestInterval != nullptr ? std::make_optional(fastestInterval->value()) : std::nullopt,
|
|
54
|
+
distanceFilter != nullptr ? std::make_optional(distanceFilter->value()) : std::nullopt,
|
|
55
|
+
useSignificantChanges != nullptr ? std::make_optional(static_cast<bool>(useSignificantChanges->value())) : std::nullopt
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
/**
|
|
61
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
62
|
+
*/
|
|
63
|
+
[[maybe_unused]]
|
|
64
|
+
static jni::local_ref<JLocationRequestOptions::javaobject> fromCpp(const LocationRequestOptions& value) {
|
|
65
|
+
using JSignature = JLocationRequestOptions(jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JDouble>, jni::alias_ref<jni::JBoolean>);
|
|
66
|
+
static const auto clazz = javaClassStatic();
|
|
67
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
68
|
+
return create(
|
|
69
|
+
clazz,
|
|
70
|
+
value.timeout.has_value() ? jni::JDouble::valueOf(value.timeout.value()) : nullptr,
|
|
71
|
+
value.maximumAge.has_value() ? jni::JDouble::valueOf(value.maximumAge.value()) : nullptr,
|
|
72
|
+
value.enableHighAccuracy.has_value() ? jni::JBoolean::valueOf(value.enableHighAccuracy.value()) : nullptr,
|
|
73
|
+
value.interval.has_value() ? jni::JDouble::valueOf(value.interval.value()) : nullptr,
|
|
74
|
+
value.fastestInterval.has_value() ? jni::JDouble::valueOf(value.fastestInterval.value()) : nullptr,
|
|
75
|
+
value.distanceFilter.has_value() ? jni::JDouble::valueOf(value.distanceFilter.value()) : nullptr,
|
|
76
|
+
value.useSignificantChanges.has_value() ? jni::JBoolean::valueOf(value.useSignificantChanges.value()) : nullptr
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JModernGeolocationConfiguration.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
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "ModernGeolocationConfiguration.hpp"
|
|
12
|
+
|
|
13
|
+
#include "AuthorizationLevel.hpp"
|
|
14
|
+
#include "JAuthorizationLevel.hpp"
|
|
15
|
+
#include "JLocationProvider.hpp"
|
|
16
|
+
#include "LocationProvider.hpp"
|
|
17
|
+
#include <optional>
|
|
18
|
+
|
|
19
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
20
|
+
|
|
21
|
+
using namespace facebook;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* The C++ JNI bridge between the C++ struct "ModernGeolocationConfiguration" and the the Kotlin data class "ModernGeolocationConfiguration".
|
|
25
|
+
*/
|
|
26
|
+
struct JModernGeolocationConfiguration final: public jni::JavaClass<JModernGeolocationConfiguration> {
|
|
27
|
+
public:
|
|
28
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/ModernGeolocationConfiguration;";
|
|
29
|
+
|
|
30
|
+
public:
|
|
31
|
+
/**
|
|
32
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ModernGeolocationConfiguration by copying all values to C++.
|
|
33
|
+
*/
|
|
34
|
+
[[maybe_unused]]
|
|
35
|
+
[[nodiscard]]
|
|
36
|
+
ModernGeolocationConfiguration toCpp() const {
|
|
37
|
+
static const auto clazz = javaClassStatic();
|
|
38
|
+
static const auto fieldAutoRequestPermission = clazz->getField<jni::JBoolean>("autoRequestPermission");
|
|
39
|
+
jni::local_ref<jni::JBoolean> autoRequestPermission = this->getFieldValue(fieldAutoRequestPermission);
|
|
40
|
+
static const auto fieldAuthorizationLevel = clazz->getField<JAuthorizationLevel>("authorizationLevel");
|
|
41
|
+
jni::local_ref<JAuthorizationLevel> authorizationLevel = this->getFieldValue(fieldAuthorizationLevel);
|
|
42
|
+
static const auto fieldEnableBackgroundLocationUpdates = clazz->getField<jni::JBoolean>("enableBackgroundLocationUpdates");
|
|
43
|
+
jni::local_ref<jni::JBoolean> enableBackgroundLocationUpdates = this->getFieldValue(fieldEnableBackgroundLocationUpdates);
|
|
44
|
+
static const auto fieldLocationProvider = clazz->getField<JLocationProvider>("locationProvider");
|
|
45
|
+
jni::local_ref<JLocationProvider> locationProvider = this->getFieldValue(fieldLocationProvider);
|
|
46
|
+
return ModernGeolocationConfiguration(
|
|
47
|
+
autoRequestPermission != nullptr ? std::make_optional(static_cast<bool>(autoRequestPermission->value())) : std::nullopt,
|
|
48
|
+
authorizationLevel != nullptr ? std::make_optional(authorizationLevel->toCpp()) : std::nullopt,
|
|
49
|
+
enableBackgroundLocationUpdates != nullptr ? std::make_optional(static_cast<bool>(enableBackgroundLocationUpdates->value())) : std::nullopt,
|
|
50
|
+
locationProvider != nullptr ? std::make_optional(locationProvider->toCpp()) : std::nullopt
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public:
|
|
55
|
+
/**
|
|
56
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
57
|
+
*/
|
|
58
|
+
[[maybe_unused]]
|
|
59
|
+
static jni::local_ref<JModernGeolocationConfiguration::javaobject> fromCpp(const ModernGeolocationConfiguration& value) {
|
|
60
|
+
using JSignature = JModernGeolocationConfiguration(jni::alias_ref<jni::JBoolean>, jni::alias_ref<JAuthorizationLevel>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<JLocationProvider>);
|
|
61
|
+
static const auto clazz = javaClassStatic();
|
|
62
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
63
|
+
return create(
|
|
64
|
+
clazz,
|
|
65
|
+
value.autoRequestPermission.has_value() ? jni::JBoolean::valueOf(value.autoRequestPermission.value()) : nullptr,
|
|
66
|
+
value.authorizationLevel.has_value() ? JAuthorizationLevel::fromCpp(value.authorizationLevel.value()) : nullptr,
|
|
67
|
+
value.enableBackgroundLocationUpdates.has_value() ? jni::JBoolean::valueOf(value.enableBackgroundLocationUpdates.value()) : nullptr,
|
|
68
|
+
value.locationProvider.has_value() ? JLocationProvider::fromCpp(value.locationProvider.value()) : nullptr
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JNullableDouble.cpp
|
|
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
|
+
#include "JNullableDouble.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
11
|
+
/**
|
|
12
|
+
* Converts JNullableDouble to std::variant<nitro::NullType, double>
|
|
13
|
+
*/
|
|
14
|
+
std::variant<nitro::NullType, double> JNullableDouble::toCpp() const {
|
|
15
|
+
if (isInstanceOf(JNullableDouble_impl::First::javaClassStatic())) {
|
|
16
|
+
// It's a `nitro::NullType`
|
|
17
|
+
auto jniValue = static_cast<const JNullableDouble_impl::First*>(this)->getValue();
|
|
18
|
+
return nitro::null;
|
|
19
|
+
} else if (isInstanceOf(JNullableDouble_impl::Second::javaClassStatic())) {
|
|
20
|
+
// It's a `double`
|
|
21
|
+
auto jniValue = static_cast<const JNullableDouble_impl::Second*>(this)->getValue();
|
|
22
|
+
return jniValue;
|
|
23
|
+
}
|
|
24
|
+
throw std::invalid_argument("Variant is unknown Kotlin instance!");
|
|
25
|
+
}
|
|
26
|
+
} // namespace margelo::nitro::nitrogeolocation
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JNullableDouble.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
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <variant>
|
|
12
|
+
|
|
13
|
+
#include <NitroModules/Null.hpp>
|
|
14
|
+
#include <variant>
|
|
15
|
+
#include <NitroModules/JNull.hpp>
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nitrogeolocation {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The C++ JNI bridge between the C++ std::variant and the Java class "NullableDouble".
|
|
23
|
+
*/
|
|
24
|
+
class JNullableDouble: public jni::JavaClass<JNullableDouble> {
|
|
25
|
+
public:
|
|
26
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/NullableDouble;";
|
|
27
|
+
|
|
28
|
+
static jni::local_ref<JNullableDouble> create_0(jni::alias_ref<JNull> value) {
|
|
29
|
+
static const auto method = javaClassStatic()->getStaticMethod<JNullableDouble(jni::alias_ref<JNull>)>("create");
|
|
30
|
+
return method(javaClassStatic(), value);
|
|
31
|
+
}
|
|
32
|
+
static jni::local_ref<JNullableDouble> create_1(double value) {
|
|
33
|
+
static const auto method = javaClassStatic()->getStaticMethod<JNullableDouble(double)>("create");
|
|
34
|
+
return method(javaClassStatic(), value);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static jni::local_ref<JNullableDouble> fromCpp(const std::variant<nitro::NullType, double>& variant) {
|
|
38
|
+
switch (variant.index()) {
|
|
39
|
+
case 0: return create_0(JNull::null());
|
|
40
|
+
case 1: return create_1(std::get<1>(variant));
|
|
41
|
+
default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[[nodiscard]] std::variant<nitro::NullType, double> toCpp() const;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
namespace JNullableDouble_impl {
|
|
49
|
+
class First final: public jni::JavaClass<First, JNullableDouble> {
|
|
50
|
+
public:
|
|
51
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/NullableDouble$First;";
|
|
52
|
+
|
|
53
|
+
[[nodiscard]] jni::local_ref<JNull> getValue() const {
|
|
54
|
+
static const auto field = javaClassStatic()->getField<JNull>("value");
|
|
55
|
+
return getFieldValue(field);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
class Second final: public jni::JavaClass<Second, JNullableDouble> {
|
|
60
|
+
public:
|
|
61
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/nitrogeolocation/NullableDouble$Second;";
|
|
62
|
+
|
|
63
|
+
[[nodiscard]] double getValue() const {
|
|
64
|
+
static const auto field = javaClassStatic()->getField<double>("value");
|
|
65
|
+
return getFieldValue(field);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
} // namespace JNullableDouble_impl
|
|
69
|
+
} // namespace margelo::nitro::nitrogeolocation
|