/// /// Metadata.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 #include #include namespace margelo::nitro::omni { /** * A struct which can be represented as a JavaScript object (Metadata). */ struct Metadata final { public: std::string title SWIFT_PRIVATE; std::optional album SWIFT_PRIVATE; std::optional artist SWIFT_PRIVATE; std::optional imageLink SWIFT_PRIVATE; public: Metadata() = default; explicit Metadata(std::string title, std::optional album, std::optional artist, std::optional imageLink): title(title), album(album), artist(artist), imageLink(imageLink) {} public: friend bool operator==(const Metadata& lhs, const Metadata& rhs) = default; }; } // namespace margelo::nitro::omni namespace margelo::nitro { // C++ Metadata <> JS Metadata (object) template <> struct JSIConverter final { static inline margelo::nitro::omni::Metadata fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) { jsi::Object obj = arg.asObject(runtime); return margelo::nitro::omni::Metadata( JSIConverter::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "title"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "album"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artist"))), JSIConverter>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "imageLink"))) ); } static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::omni::Metadata& arg) { jsi::Object obj(runtime); obj.setProperty(runtime, PropNameIDCache::get(runtime, "title"), JSIConverter::toJSI(runtime, arg.title)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "album"), JSIConverter>::toJSI(runtime, arg.album)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "artist"), JSIConverter>::toJSI(runtime, arg.artist)); obj.setProperty(runtime, PropNameIDCache::get(runtime, "imageLink"), JSIConverter>::toJSI(runtime, arg.imageLink)); 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, "title")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "album")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artist")))) return false; if (!JSIConverter>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "imageLink")))) return false; return true; } }; } // namespace margelo::nitro