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

#pragma once

#include "HybridNitroDnsSpec.hpp"

// Forward declaration of `HybridNitroDnsSpec_cxx` to properly resolve imports.
namespace RNDns { class HybridNitroDnsSpec_cxx; }

// Forward declaration of `HybridNitroResolverSpec` to properly resolve imports.
namespace margelo::nitro::nitro_dns { class HybridNitroResolverSpec; }
// Forward declaration of `CachePolicy` to properly resolve imports.
namespace margelo::nitro::nitro_dns { enum class CachePolicy; }

#include <memory>
#include "HybridNitroResolverSpec.hpp"
#include <string>
#include <optional>
#include <NitroModules/Promise.hpp>
#include "CachePolicy.hpp"

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

namespace margelo::nitro::nitro_dns {

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

  public:
    // Get the Swift part
    inline RNDns::HybridNitroDnsSpec_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<HybridNitroDnsSpecSwift>(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<HybridNitroResolverSpec> createResolver(const std::optional<std::string>& config) override {
      auto __result = _swiftPart.createResolver(config);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::string getServers() override {
      auto __result = _swiftPart.getServers();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void setServers(const std::string& servers) override {
      auto __result = _swiftPart.setServers(servers);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline std::string lookup(const std::string& hostname, double family) override {
      auto __result = _swiftPart.lookup(hostname, std::forward<decltype(family)>(family));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolve4(const std::string& hostname) override {
      auto __result = _swiftPart.resolve4(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolve6(const std::string& hostname) override {
      auto __result = _swiftPart.resolve6(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveMx(const std::string& hostname) override {
      auto __result = _swiftPart.resolveMx(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveTxt(const std::string& hostname) override {
      auto __result = _swiftPart.resolveTxt(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveCname(const std::string& hostname) override {
      auto __result = _swiftPart.resolveCname(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveNs(const std::string& hostname) override {
      auto __result = _swiftPart.resolveNs(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveSoa(const std::string& hostname) override {
      auto __result = _swiftPart.resolveSoa(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveSrv(const std::string& hostname) override {
      auto __result = _swiftPart.resolveSrv(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveCaa(const std::string& hostname) override {
      auto __result = _swiftPart.resolveCaa(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveNaptr(const std::string& hostname) override {
      auto __result = _swiftPart.resolveNaptr(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolvePtr(const std::string& hostname) override {
      auto __result = _swiftPart.resolvePtr(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveTlsa(const std::string& hostname) override {
      auto __result = _swiftPart.resolveTlsa(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> resolveAny(const std::string& hostname) override {
      auto __result = _swiftPart.resolveAny(hostname);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> reverse(const std::string& ip) override {
      auto __result = _swiftPart.reverse(ip);
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::string>> lookupService(const std::string& address, double port) override {
      auto __result = _swiftPart.lookupService(address, std::forward<decltype(port)>(port));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline void setNativeInterceptionEnabled(bool enabled) override {
      auto __result = _swiftPart.setNativeInterceptionEnabled(std::forward<decltype(enabled)>(enabled));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void setVerbose(bool enabled) override {
      auto __result = _swiftPart.setVerbose(std::forward<decltype(enabled)>(enabled));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void clearCache() override {
      auto __result = _swiftPart.clearCache();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void setCacheSize(double size) override {
      auto __result = _swiftPart.setCacheSize(std::forward<decltype(size)>(size));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }
    inline void setCachePolicy(CachePolicy policy, double staleTtl) override {
      auto __result = _swiftPart.setCachePolicy(static_cast<int>(policy), std::forward<decltype(staleTtl)>(staleTtl));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
    }

  private:
    RNDns::HybridNitroDnsSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::nitro_dns
