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

#pragma once

#include "HybridCloudKitModuleSpec.hpp"

// Forward declaration of `HybridCloudKitModuleSpec_cxx` to properly resolve imports.
namespace CloudKitModule { class HybridCloudKitModuleSpec_cxx; }

// Forward declaration of `AccountInfoResult` to properly resolve imports.
namespace margelo::nitro::cloudkitmodule { struct AccountInfoResult; }
// Forward declaration of `SaveRecordResult` to properly resolve imports.
namespace margelo::nitro::cloudkitmodule { struct SaveRecordResult; }
// Forward declaration of `SaveRecordParams` to properly resolve imports.
namespace margelo::nitro::cloudkitmodule { struct SaveRecordParams; }
// Forward declaration of `RecordResult` to properly resolve imports.
namespace margelo::nitro::cloudkitmodule { struct RecordResult; }
// Forward declaration of `FetchRecordParams` to properly resolve imports.
namespace margelo::nitro::cloudkitmodule { struct FetchRecordParams; }
// Forward declaration of `DeleteRecordParams` to properly resolve imports.
namespace margelo::nitro::cloudkitmodule { struct DeleteRecordParams; }
// Forward declaration of `RecordExistsParams` to properly resolve imports.
namespace margelo::nitro::cloudkitmodule { struct RecordExistsParams; }
// Forward declaration of `QueryRecordsResult` to properly resolve imports.
namespace margelo::nitro::cloudkitmodule { struct QueryRecordsResult; }
// Forward declaration of `QueryRecordsParams` to properly resolve imports.
namespace margelo::nitro::cloudkitmodule { struct QueryRecordsParams; }

#include <NitroModules/Promise.hpp>
#include "AccountInfoResult.hpp"
#include <string>
#include <optional>
#include "SaveRecordResult.hpp"
#include "SaveRecordParams.hpp"
#include <NitroModules/Null.hpp>
#include "RecordResult.hpp"
#include <variant>
#include "FetchRecordParams.hpp"
#include "DeleteRecordParams.hpp"
#include "RecordExistsParams.hpp"
#include "QueryRecordsResult.hpp"
#include <vector>
#include "QueryRecordsParams.hpp"

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

namespace margelo::nitro::cloudkitmodule {

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

  public:
    // Get the Swift part
    inline CloudKitModule::HybridCloudKitModuleSpec_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<HybridCloudKitModuleSpecSwift>(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<Promise<bool>> isAvailable() override {
      auto __result = _swiftPart.isAvailable();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<AccountInfoResult>> getAccountInfo() override {
      auto __result = _swiftPart.getAccountInfo();
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<SaveRecordResult>> saveRecord(const SaveRecordParams& params) override {
      auto __result = _swiftPart.saveRecord(std::forward<decltype(params)>(params));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<std::variant<nitro::NullType, RecordResult>>> fetchRecord(const FetchRecordParams& params) override {
      auto __result = _swiftPart.fetchRecord(std::forward<decltype(params)>(params));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<void>> deleteRecord(const DeleteRecordParams& params) override {
      auto __result = _swiftPart.deleteRecord(std::forward<decltype(params)>(params));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<bool>> recordExists(const RecordExistsParams& params) override {
      auto __result = _swiftPart.recordExists(std::forward<decltype(params)>(params));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }
    inline std::shared_ptr<Promise<QueryRecordsResult>> queryRecords(const QueryRecordsParams& params) override {
      auto __result = _swiftPart.queryRecords(std::forward<decltype(params)>(params));
      if (__result.hasError()) [[unlikely]] {
        std::rethrow_exception(__result.error());
      }
      auto __value = std::move(__result.value());
      return __value;
    }

  private:
    CloudKitModule::HybridCloudKitModuleSpec_cxx _swiftPart;
  };

} // namespace margelo::nitro::cloudkitmodule
