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

#pragma once

#include "HybridNitroFetchSpec.hpp"

// Forward declaration of `HybridNitroFetchSpec_cxx` to properly resolve imports.
namespace NitroFetch { class HybridNitroFetchSpec_cxx; }

// Forward declaration of `HybridNitroFetchClientSpec` to properly resolve imports.
namespace margelo::nitro::nitrofetch { class HybridNitroFetchClientSpec; }

#include <memory>
#include "HybridNitroFetchClientSpec.hpp"

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

namespace margelo::nitro::nitrofetch {

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

  public:
    // Get the Swift part
    inline NitroFetch::HybridNitroFetchSpec_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<HybridNitroFetchSpecSwift>(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 std::shared_ptr<HybridNitroFetchClientSpec> createClient() override {
      auto __result = _swiftPart.createClient();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    NitroFetch::HybridNitroFetchSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::nitrofetch
