Files
2026-07-31 16:20:10 +02:00

115 lines
6.7 KiB
C++
Generated

///
/// 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(<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 `HealthMetricType` to properly resolve imports.
namespace margelo::nitro::haptika::ppg { enum class HealthMetricType; }
#include "HealthMetricType.hpp"
#include <string>
#include <optional>
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<std::string> sourceName SWIFT_PRIVATE;
std::optional<std::string> sourceBundleIdentifier SWIFT_PRIVATE;
std::optional<std::string> deviceName SWIFT_PRIVATE;
public:
NativeHealthMetricSample() = default;
explicit NativeHealthMetricSample(HealthMetricType type, double value, std::string unit, std::string startDate, std::string endDate, std::optional<std::string> sourceName, std::optional<std::string> sourceBundleIdentifier, std::optional<std::string> 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<margelo::nitro::haptika::ppg::NativeHealthMetricSample> 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<margelo::nitro::haptika::ppg::HealthMetricType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value"))),
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unit"))),
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startDate"))),
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endDate"))),
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceName"))),
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceBundleIdentifier"))),
JSIConverter<std::optional<std::string>>::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<margelo::nitro::haptika::ppg::HealthMetricType>::toJSI(runtime, arg.type));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<double>::toJSI(runtime, arg.value));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "unit"), JSIConverter<std::string>::toJSI(runtime, arg.unit));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "startDate"), JSIConverter<std::string>::toJSI(runtime, arg.startDate));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "endDate"), JSIConverter<std::string>::toJSI(runtime, arg.endDate));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "sourceName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.sourceName));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "sourceBundleIdentifier"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.sourceBundleIdentifier));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "deviceName"), JSIConverter<std::optional<std::string>>::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<margelo::nitro::haptika::ppg::HealthMetricType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unit")))) return false;
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "startDate")))) return false;
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "endDate")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceName")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "sourceBundleIdentifier")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deviceName")))) return false;
return true;
}
};
} // namespace margelo::nitro