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

#pragma once

#include "HybridOneMailComposeSpec.hpp"

// Forward declaration of `HybridOneMailComposeSpec_cxx` to properly resolve imports.
namespace One { class HybridOneMailComposeSpec_cxx; }

// Forward declaration of `ArrayBufferHolder` to properly resolve imports.
namespace NitroModules { class ArrayBufferHolder; }
// Forward declaration of `MailComposeResult` to properly resolve imports.
namespace margelo::nitro::one { enum class MailComposeResult; }
// Forward declaration of `DocumentCameraError` to properly resolve imports.
namespace margelo::nitro::one { struct DocumentCameraError; }

#include <string>
#include <vector>
#include <NitroModules/ArrayBuffer.hpp>
#include <NitroModules/ArrayBufferHolder.hpp>
#include <NitroModules/Promise.hpp>
#include "MailComposeResult.hpp"
#include "DocumentCameraError.hpp"
#include <optional>
#include <functional>

#include "One-Swift-Cxx-Umbrella.hpp"

namespace margelo::nitro::one {

  /**
   * The C++ part of HybridOneMailComposeSpec_cxx.swift.
   *
   * HybridOneMailComposeSpecSwift (C++) accesses HybridOneMailComposeSpec_cxx (Swift), and might
   * contain some additional bridging code for C++ <> Swift interop.
   *
   * Since this obviously introduces an overhead, I hope at some point in
   * the future, HybridOneMailComposeSpec_cxx can directly inherit from the C++ class HybridOneMailComposeSpec
   * to simplify the whole structure and memory management.
   */
  class HybridOneMailComposeSpecSwift: public virtual HybridOneMailComposeSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridOneMailComposeSpecSwift(const One::HybridOneMailComposeSpec_cxx& swiftPart):
      HybridObject(HybridOneMailComposeSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline One::HybridOneMailComposeSpec_cxx& getSwiftPart() noexcept {
      return _swiftPart;
    }

  public:
    inline size_t getExternalMemorySize() noexcept override {
      return _swiftPart.getMemorySize();
    }
    bool equals(const std::shared_ptr<HybridObject>& other) override {
      if (auto otherCast = std::dynamic_pointer_cast<HybridOneMailComposeSpecSwift>(other)) {
        return _swiftPart.equals(otherCast->_swiftPart);
      }
      return false;
    }
    void dispose() noexcept override {
      _swiftPart.dispose();
    }
    std::string toString() override {
      return _swiftPart.toString();
    }

  public:
    // Properties
    

  public:
    // Methods
    inline bool canSendMail() override {
      auto __result = _swiftPart.canSendMail();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void setSubject(const std::string& subject) override {
      auto __result = _swiftPart.setSubject(subject);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void setToRecipients(const std::vector<std::string>& recipients) override {
      auto __result = _swiftPart.setToRecipients(recipients);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void setCcRecipients(const std::vector<std::string>& recipients) override {
      auto __result = _swiftPart.setCcRecipients(recipients);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void setBccRecipients(const std::vector<std::string>& recipients) override {
      auto __result = _swiftPart.setBccRecipients(recipients);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void setMessageBody(const std::string& body, bool isHTML) override {
      auto __result = _swiftPart.setMessageBody(body, std::forward<decltype(isHTML)>(isHTML));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void setPreferredSendingEmailAddress(const std::string& emailAddress) override {
      auto __result = _swiftPart.setPreferredSendingEmailAddress(emailAddress);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void addAttachmentData(const std::shared_ptr<ArrayBuffer>& attachment, const std::string& mimeType, const std::string& fileName) override {
      auto __result = _swiftPart.addAttachmentData(ArrayBufferHolder(attachment), mimeType, fileName);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::shared_ptr<Promise<void>> present(bool animated, const std::function<void(MailComposeResult /* result */, const std::optional<DocumentCameraError>& /* error */)>& didFinish) override {
      auto __result = _swiftPart.present(std::forward<decltype(animated)>(animated), didFinish);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> dismiss(bool animated) override {
      auto __result = _swiftPart.dismiss(std::forward<decltype(animated)>(animated));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    One::HybridOneMailComposeSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::one
