///
/// NitroTextToSpeech-Swift-Cxx-Bridge.cpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2024 Marc Rousavy @ Margelo
///

#include "NitroTextToSpeech-Swift-Cxx-Bridge.hpp"

// Include C++ implementation defined types
#include "HybridTextToSpeechSpecSwift.hpp"
#include "NitroTextToSpeech-Swift-Cxx-Umbrella.hpp"

namespace margelo::nitro::nitrotexttospeech::bridge::swift {

  // pragma MARK: std::function<void()>
  Func_void create_Func_void(void* _Nonnull swiftClosureWrapper) {
    auto swiftClosure = NitroTextToSpeech::Func_void::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)]() mutable -> void {
      swiftClosure.call();
    };
  }
  
  // pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
  Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* _Nonnull swiftClosureWrapper) {
    auto swiftClosure = NitroTextToSpeech::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
      swiftClosure.call(error);
    };
  }
  
  // pragma MARK: std::function<void(bool /* result */)>
  Func_void_bool create_Func_void_bool(void* _Nonnull swiftClosureWrapper) {
    auto swiftClosure = NitroTextToSpeech::Func_void_bool::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](bool result) mutable -> void {
      swiftClosure.call(result);
    };
  }
  
  // pragma MARK: std::function<void(const std::vector<TextToSpeechVoice>& /* result */)>
  Func_void_std__vector_TextToSpeechVoice_ create_Func_void_std__vector_TextToSpeechVoice_(void* _Nonnull swiftClosureWrapper) {
    auto swiftClosure = NitroTextToSpeech::Func_void_std__vector_TextToSpeechVoice_::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::vector<TextToSpeechVoice>& result) mutable -> void {
      swiftClosure.call(result);
    };
  }
  
  // pragma MARK: std::function<void(const std::optional<std::string>& /* word */)>
  Func_void_std__optional_std__string_ create_Func_void_std__optional_std__string_(void* _Nonnull swiftClosureWrapper) {
    auto swiftClosure = NitroTextToSpeech::Func_void_std__optional_std__string_::fromUnsafe(swiftClosureWrapper);
    return [swiftClosure = std::move(swiftClosure)](const std::optional<std::string>& word) mutable -> void {
      swiftClosure.call(word);
    };
  }
  
  // pragma MARK: std::shared_ptr<margelo::nitro::nitrotexttospeech::HybridTextToSpeechSpec>
  std::shared_ptr<margelo::nitro::nitrotexttospeech::HybridTextToSpeechSpec> create_std__shared_ptr_margelo__nitro__nitrotexttospeech__HybridTextToSpeechSpec_(void* _Nonnull swiftUnsafePointer) {
    NitroTextToSpeech::HybridTextToSpeechSpec_cxx swiftPart = NitroTextToSpeech::HybridTextToSpeechSpec_cxx::fromUnsafe(swiftUnsafePointer);
    return std::make_shared<margelo::nitro::nitrotexttospeech::HybridTextToSpeechSpecSwift>(swiftPart);
  }
  void* _Nonnull get_std__shared_ptr_margelo__nitro__nitrotexttospeech__HybridTextToSpeechSpec_(std__shared_ptr_margelo__nitro__nitrotexttospeech__HybridTextToSpeechSpec_ cppType) {
    std::shared_ptr<margelo::nitro::nitrotexttospeech::HybridTextToSpeechSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitrotexttospeech::HybridTextToSpeechSpecSwift>(cppType);
  #ifdef NITRO_DEBUG
    if (swiftWrapper == nullptr) [[unlikely]] {
      throw std::runtime_error("Class \"HybridTextToSpeechSpec\" is not implemented in Swift!");
    }
  #endif
    NitroTextToSpeech::HybridTextToSpeechSpec_cxx swiftPart = swiftWrapper->getSwiftPart();
    return swiftPart.toUnsafe();
  }

} // namespace margelo::nitro::nitrotexttospeech::bridge::swift
