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

#pragma once

#include "HybridNativeListDataSourceSpec.hpp"

// Forward declaration of `HybridNativeListDataSourceSpec_cxx` to properly resolve imports.
namespace ReactNativeList { class HybridNativeListDataSourceSpec_cxx; }

// Forward declaration of `NativeListItem` to properly resolve imports.
namespace margelo::nitro::reactnativelist { struct NativeListItem; }

#include "NativeListItem.hpp"
#include <functional>
#include <string>
#include <optional>
#include <NitroModules/AnyMap.hpp>
#include <vector>

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

namespace margelo::nitro::reactnativelist {

  /**
   * The C++ part of HybridNativeListDataSourceSpec_cxx.swift.
   *
   * HybridNativeListDataSourceSpecSwift (C++) accesses HybridNativeListDataSourceSpec_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, HybridNativeListDataSourceSpec_cxx can directly inherit from the C++ class HybridNativeListDataSourceSpec
   * to simplify the whole structure and memory management.
   */
  class HybridNativeListDataSourceSpecSwift: public virtual HybridNativeListDataSourceSpec {
  public:
    // Constructor from a Swift instance
    explicit HybridNativeListDataSourceSpecSwift(const ReactNativeList::HybridNativeListDataSourceSpec_cxx& swiftPart):
      HybridObject(HybridNativeListDataSourceSpec::TAG),
      _swiftPart(swiftPart) { }

  public:
    // Get the Swift part
    inline ReactNativeList::HybridNativeListDataSourceSpec_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<HybridNativeListDataSourceSpecSwift>(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 void setContentEqualCallback(const std::function<bool(const NativeListItem& /* oldItem */, const NativeListItem& /* newItem */)>& isContentEqual) override {
      auto __result = _swiftPart.setContentEqualCallback(isContentEqual);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void replaceData(const std::vector<NativeListItem>& items, bool animated) override {
      auto __result = _swiftPart.replaceData(items, std::forward<decltype(animated)>(animated));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void insertItem(double index, const NativeListItem& item) override {
      auto __result = _swiftPart.insertItem(std::forward<decltype(index)>(index), std::forward<decltype(item)>(item));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void updateItem(double index, const NativeListItem& item) override {
      auto __result = _swiftPart.updateItem(std::forward<decltype(index)>(index), std::forward<decltype(item)>(item));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void removeItem(double index) override {
      auto __result = _swiftPart.removeItem(std::forward<decltype(index)>(index));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void moveItem(double fromIndex, double toIndex) override {
      auto __result = _swiftPart.moveItem(std::forward<decltype(fromIndex)>(fromIndex), std::forward<decltype(toIndex)>(toIndex));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline double getCount() override {
      auto __result = _swiftPart.getCount();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline NativeListItem getItem(double index) override {
      auto __result = _swiftPart.getItem(std::forward<decltype(index)>(index));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    ReactNativeList::HybridNativeListDataSourceSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::reactnativelist
