112 lines
6.8 KiB
C++
Generated
112 lines
6.8 KiB
C++
Generated
///
|
|
/// NativeHealthKitContext.hpp
|
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
/// https://github.com/mrousavy/nitro
|
|
/// Copyright © Marc Rousavy @ Margelo
|
|
///
|
|
|
|
#pragma once
|
|
|
|
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
#include <NitroModules/JSIConverter.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
#include <NitroModules/NitroDefines.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
#include <NitroModules/JSIHelpers.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
#include <NitroModules/PropNameIDCache.hpp>
|
|
#else
|
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
#endif
|
|
|
|
// Forward declaration of `NativeHealthMetricSample` to properly resolve imports.
|
|
namespace margelo::nitro::haptika::ppg { struct NativeHealthMetricSample; }
|
|
|
|
#include "NativeHealthMetricSample.hpp"
|
|
#include <optional>
|
|
#include <vector>
|
|
#include <string>
|
|
|
|
namespace margelo::nitro::haptika::ppg {
|
|
|
|
/**
|
|
* A struct which can be represented as a JavaScript object (NativeHealthKitContext).
|
|
*/
|
|
struct NativeHealthKitContext final {
|
|
public:
|
|
bool available SWIFT_PRIVATE;
|
|
bool authorized SWIFT_PRIVATE;
|
|
std::optional<NativeHealthMetricSample> latestRestingHeartRate SWIFT_PRIVATE;
|
|
std::optional<NativeHealthMetricSample> latestHrvSdnn SWIFT_PRIVATE;
|
|
std::vector<NativeHealthMetricSample> recentHeartRateSamples SWIFT_PRIVATE;
|
|
double contextConfidence SWIFT_PRIVATE;
|
|
std::string fetchedAt SWIFT_PRIVATE;
|
|
|
|
public:
|
|
NativeHealthKitContext() = default;
|
|
explicit NativeHealthKitContext(bool available, bool authorized, std::optional<NativeHealthMetricSample> latestRestingHeartRate, std::optional<NativeHealthMetricSample> latestHrvSdnn, std::vector<NativeHealthMetricSample> recentHeartRateSamples, double contextConfidence, std::string fetchedAt): available(available), authorized(authorized), latestRestingHeartRate(latestRestingHeartRate), latestHrvSdnn(latestHrvSdnn), recentHeartRateSamples(recentHeartRateSamples), contextConfidence(contextConfidence), fetchedAt(fetchedAt) {}
|
|
|
|
public:
|
|
friend bool operator==(const NativeHealthKitContext& lhs, const NativeHealthKitContext& rhs) = default;
|
|
};
|
|
|
|
} // namespace margelo::nitro::haptika::ppg
|
|
|
|
namespace margelo::nitro {
|
|
|
|
// C++ NativeHealthKitContext <> JS NativeHealthKitContext (object)
|
|
template <>
|
|
struct JSIConverter<margelo::nitro::haptika::ppg::NativeHealthKitContext> final {
|
|
static inline margelo::nitro::haptika::ppg::NativeHealthKitContext fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
jsi::Object obj = arg.asObject(runtime);
|
|
return margelo::nitro::haptika::ppg::NativeHealthKitContext(
|
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "available"))),
|
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "authorized"))),
|
|
JSIConverter<std::optional<margelo::nitro::haptika::ppg::NativeHealthMetricSample>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latestRestingHeartRate"))),
|
|
JSIConverter<std::optional<margelo::nitro::haptika::ppg::NativeHealthMetricSample>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latestHrvSdnn"))),
|
|
JSIConverter<std::vector<margelo::nitro::haptika::ppg::NativeHealthMetricSample>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "recentHeartRateSamples"))),
|
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "contextConfidence"))),
|
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fetchedAt")))
|
|
);
|
|
}
|
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::haptika::ppg::NativeHealthKitContext& arg) {
|
|
jsi::Object obj(runtime);
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "available"), JSIConverter<bool>::toJSI(runtime, arg.available));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "authorized"), JSIConverter<bool>::toJSI(runtime, arg.authorized));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "latestRestingHeartRate"), JSIConverter<std::optional<margelo::nitro::haptika::ppg::NativeHealthMetricSample>>::toJSI(runtime, arg.latestRestingHeartRate));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "latestHrvSdnn"), JSIConverter<std::optional<margelo::nitro::haptika::ppg::NativeHealthMetricSample>>::toJSI(runtime, arg.latestHrvSdnn));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "recentHeartRateSamples"), JSIConverter<std::vector<margelo::nitro::haptika::ppg::NativeHealthMetricSample>>::toJSI(runtime, arg.recentHeartRateSamples));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "contextConfidence"), JSIConverter<double>::toJSI(runtime, arg.contextConfidence));
|
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "fetchedAt"), JSIConverter<std::string>::toJSI(runtime, arg.fetchedAt));
|
|
return obj;
|
|
}
|
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
if (!value.isObject()) {
|
|
return false;
|
|
}
|
|
jsi::Object obj = value.getObject(runtime);
|
|
if (!nitro::isPlainObject(runtime, obj)) {
|
|
return false;
|
|
}
|
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "available")))) return false;
|
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "authorized")))) return false;
|
|
if (!JSIConverter<std::optional<margelo::nitro::haptika::ppg::NativeHealthMetricSample>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latestRestingHeartRate")))) return false;
|
|
if (!JSIConverter<std::optional<margelo::nitro::haptika::ppg::NativeHealthMetricSample>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "latestHrvSdnn")))) return false;
|
|
if (!JSIConverter<std::vector<margelo::nitro::haptika::ppg::NativeHealthMetricSample>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "recentHeartRateSamples")))) return false;
|
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "contextConfidence")))) return false;
|
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fetchedAt")))) return false;
|
|
return true;
|
|
}
|
|
};
|
|
|
|
} // namespace margelo::nitro
|