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

#pragma once

#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif



#include <string>
#include <optional>

namespace margelo::nitro::crypto {

  /**
   * A struct which can be represented as a JavaScript object (CipherInfo).
   */
  struct CipherInfo final {
  public:
    std::string name     SWIFT_PRIVATE;
    double nid     SWIFT_PRIVATE;
    std::string mode     SWIFT_PRIVATE;
    double keyLength     SWIFT_PRIVATE;
    std::optional<double> blockSize     SWIFT_PRIVATE;
    std::optional<double> ivLength     SWIFT_PRIVATE;

  public:
    CipherInfo() = default;
    explicit CipherInfo(std::string name, double nid, std::string mode, double keyLength, std::optional<double> blockSize, std::optional<double> ivLength): name(name), nid(nid), mode(mode), keyLength(keyLength), blockSize(blockSize), ivLength(ivLength) {}

  public:
    friend bool operator==(const CipherInfo& lhs, const CipherInfo& rhs) = default;
  };

} // namespace margelo::nitro::crypto

namespace margelo::nitro {

  // C++ CipherInfo <> JS CipherInfo (object)
  template <>
  struct JSIConverter<margelo::nitro::crypto::CipherInfo> final {
    static inline margelo::nitro::crypto::CipherInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::crypto::CipherInfo(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "nid"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mode"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "keyLength"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "blockSize"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ivLength")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::crypto::CipherInfo& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "nid"), JSIConverter<double>::toJSI(runtime, arg.nid));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "mode"), JSIConverter<std::string>::toJSI(runtime, arg.mode));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "keyLength"), JSIConverter<double>::toJSI(runtime, arg.keyLength));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "blockSize"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.blockSize));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "ivLength"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.ivLength));
      return obj;
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isObject()) {
        return false;
      }
      jsi::Object obj = value.getObject(runtime);
      if (!nitro::isPlainObject(runtime, obj)) {
        return false;
      }
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "nid")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mode")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "keyLength")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "blockSize")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ivLength")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
