/// /// NativeHealthMetricSample.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() #include #else #error NitroModules cannot be found! Are you sure you installed NitroModules properly? #endif #if __has_include() #include #else #error NitroModules cannot be found! Are you sure you installed NitroModules properly? #endif #if __has_include() #include #else #error NitroModules cannot be found! Are you sure you installed NitroModules properly? #endif #if __has_include() #include #else #error NitroModules cannot be found! Are you sure you installed NitroModules properly? #endif // Forward declaration of `HealthMetricType` to properly resolve imports. namespace margelo::nitro::haptika::ppg { enum class HealthMetricType; } #include "HealthMetricType.hpp" #include #include namespace margelo::nitro::haptika::ppg { /** * A struct which can be represented as a JavaScript object (NativeHealthMetricSample). */ struct NativeHealthMetricSample final { public: HealthMetricType type SWIFT_PRIVATE; double value SWIFT_PRIVATE; std::string unit SWIFT_PRIVATE; std::string startDate SWIFT_PRIVATE; std::string endDate SWIFT_PRIVATE; std::optional sourceName SWIFT_PRIVATE; std::optional sourceBundleIdentifier SWIFT_PRIVATE; std::optional deviceName SWIFT_PRIVATE; public: NativeHealthMetricSample() = default; explicit NativeHealthMetricSample(HealthMetricType type, double value, std::string unit, std::string startDate, std::string endDate, std::optional sourceName, std::optional sourceBundleIdentifier, std::optional deviceName): type(type), value(value), unit(unit), startDate(startDate), endDate(endDate), sourceName(sourceName), sourceBundleIdentifier(sourceBundleIdentifier), deviceName(deviceName) {} public: friend bool operator==(const NativeHealthMetricSample& lhs, const NativeHealthMetricSample& rhs) = default; }; } // namespace margelo::nitro::haptika::ppg namespace margelo::nitro { // C++ NativeHealthMetricSample <> JS NativeHealthMetricSample (object) template <> struct JSIConverter final { static inline margelo::nitro::haptika::ppg::NativeHealthMetricSample fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { jsi::Object obj = arg.asObject(runtime); return margelo::nitro::haptika::ppg::NativeHealthMetricSample( JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))), JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value"))), JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unit"))), JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startDate"))), JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endDate"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceName"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceBundleIdentifier"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deviceName"))) ); } static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::haptika::ppg::NativeHealthMetricSample& arg) { jsi::Object obj(runtime); obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter::toJSI(runtime, arg.type)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter::toJSI(runtime, arg.value)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "unit"), JSIConverter::toJSI(runtime, arg.unit)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "startDate"), JSIConverter::toJSI(runtime, arg.startDate)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "endDate"), JSIConverter::toJSI(runtime, arg.endDate)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "sourceName"), JSIConverter>::toJSI(runtime, arg.sourceName)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "sourceBundleIdentifier"), JSIConverter>::toJSI(runtime, arg.sourceBundleIdentifier)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "deviceName"), JSIConverter>::toJSI(runtime, arg.deviceName)); 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::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false; if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false; if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unit")))) return false; if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startDate")))) return false; if (!JSIConverter::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endDate")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceName")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceBundleIdentifier")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deviceName")))) return false; return true; } }; } // namespace margelo::nitro