///
/// JFunc_void_std__vector_std__string_.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///

#pragma once

#include <fbjni/fbjni.h>
#include <functional>

#include <string>
#include <vector>
#include <functional>

namespace margelo::nitro::video {

  using namespace facebook;

  /**
   * Represents the Java/Kotlin callback `(texts: Array<String>) -> Unit`.
   * This can be passed around between C++ and Java/Kotlin.
   */
  struct JFunc_void_std__vector_std__string_: public jni::JavaClass<JFunc_void_std__vector_std__string_> {
  public:
    static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_std__vector_std__string_;";

  public:
    /**
     * Invokes the function this `JFunc_void_std__vector_std__string_` instance holds through JNI.
     */
    void invoke(const std::vector<std::string>& texts) const {
      static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<jni::JArrayClass<jni::JString>> /* texts */)>("invoke");
      method(self(), [&]() {
        size_t __size = texts.size();
        jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
        for (size_t __i = 0; __i < __size; __i++) {
          const auto& __element = texts[__i];
          __array->setElement(__i, *jni::make_jstring(__element));
        }
        return __array;
      }());
    }
  };

  /**
   * An implementation of Func_void_std__vector_std__string_ that is backed by a C++ implementation (using `std::function<...>`)
   */
  struct JFunc_void_std__vector_std__string__cxx final: public jni::HybridClass<JFunc_void_std__vector_std__string__cxx, JFunc_void_std__vector_std__string_> {
  public:
    static jni::local_ref<JFunc_void_std__vector_std__string_::javaobject> fromCpp(const std::function<void(const std::vector<std::string>& /* texts */)>& func) {
      return JFunc_void_std__vector_std__string__cxx::newObjectCxxArgs(func);
    }

  public:
    /**
     * Invokes the C++ `std::function<...>` this `JFunc_void_std__vector_std__string__cxx` instance holds.
     */
    void invoke_cxx(jni::alias_ref<jni::JArrayClass<jni::JString>> texts) {
      _func([&]() {
              size_t __size = texts->size();
              std::vector<std::string> __vector;
              __vector.reserve(__size);
              for (size_t __i = 0; __i < __size; __i++) {
                auto __element = texts->getElement(__i);
                __vector.push_back(__element->toStdString());
              }
              return __vector;
            }());
    }

  public:
    [[nodiscard]]
    inline const std::function<void(const std::vector<std::string>& /* texts */)>& getFunction() const {
      return _func;
    }

  public:
    static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/video/Func_void_std__vector_std__string__cxx;";
    static void registerNatives() {
      registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__vector_std__string__cxx::invoke_cxx)});
    }

  private:
    explicit JFunc_void_std__vector_std__string__cxx(const std::function<void(const std::vector<std::string>& /* texts */)>& func): _func(func) { }

  private:
    friend HybridBase;
    std::function<void(const std::vector<std::string>& /* texts */)> _func;
  };

} // namespace margelo::nitro::video
