/// /// JSubtitle.hpp /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE. /// https://github.com/mrousavy/nitro /// Copyright © Marc Rousavy @ Margelo /// #pragma once #include #include "Subtitle.hpp" #include #include namespace margelo::nitro::omni { using namespace facebook; /** * The C++ JNI bridge between the C++ struct "Subtitle" and the the Kotlin data class "Subtitle". */ struct JSubtitle final: public jni::JavaClass { public: static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/Subtitle;"; public: /** * Convert this Java/Kotlin-based struct to the C++ struct Subtitle by copying all values to C++. */ [[maybe_unused]] [[nodiscard]] Subtitle toCpp() const { static const auto clazz = javaClassStatic(); static const auto fieldId = clazz->getField("id"); jni::local_ref id = this->getFieldValue(fieldId); static const auto fieldLink = clazz->getField("link"); jni::local_ref link = this->getFieldValue(fieldLink); static const auto fieldMimeType = clazz->getField("mimeType"); jni::local_ref mimeType = this->getFieldValue(fieldMimeType); static const auto fieldLanguage = clazz->getField("language"); jni::local_ref language = this->getFieldValue(fieldLanguage); static const auto fieldLabel = clazz->getField("label"); jni::local_ref label = this->getFieldValue(fieldLabel); return Subtitle( id->toStdString(), link->toStdString(), mimeType != nullptr ? std::make_optional(mimeType->toStdString()) : std::nullopt, language != nullptr ? std::make_optional(language->toStdString()) : std::nullopt, label != nullptr ? std::make_optional(label->toStdString()) : std::nullopt ); } public: /** * Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java. */ [[maybe_unused]] static jni::local_ref fromCpp(const Subtitle& value) { using JSignature = JSubtitle(jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref, jni::alias_ref); static const auto clazz = javaClassStatic(); static const auto create = clazz->getStaticMethod("fromCpp"); return create( clazz, jni::make_jstring(value.id), jni::make_jstring(value.link), value.mimeType.has_value() ? jni::make_jstring(value.mimeType.value()) : nullptr, value.language.has_value() ? jni::make_jstring(value.language.value()) : nullptr, value.label.has_value() ? jni::make_jstring(value.label.value()) : nullptr ); } }; } // namespace margelo::nitro::omni