///
/// NumericColumn.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 <NitroModules/ArrayBuffer.hpp>
#include <string>

namespace margelo::nitro::rnduckdb {

  /**
   * A struct which can be represented as a JavaScript object (NumericColumn).
   */
  struct NumericColumn final {
  public:
    std::shared_ptr<ArrayBuffer> data     SWIFT_PRIVATE;
    std::shared_ptr<ArrayBuffer> validity     SWIFT_PRIVATE;
    std::string dtype     SWIFT_PRIVATE;

  public:
    NumericColumn() = default;
    explicit NumericColumn(std::shared_ptr<ArrayBuffer> data, std::shared_ptr<ArrayBuffer> validity, std::string dtype): data(data), validity(validity), dtype(dtype) {}

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

} // namespace margelo::nitro::rnduckdb

namespace margelo::nitro {

  // C++ NumericColumn <> JS NumericColumn (object)
  template <>
  struct JSIConverter<margelo::nitro::rnduckdb::NumericColumn> final {
    static inline margelo::nitro::rnduckdb::NumericColumn fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::rnduckdb::NumericColumn(
        JSIConverter<std::shared_ptr<ArrayBuffer>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data"))),
        JSIConverter<std::shared_ptr<ArrayBuffer>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "validity"))),
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dtype")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::rnduckdb::NumericColumn& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "data"), JSIConverter<std::shared_ptr<ArrayBuffer>>::toJSI(runtime, arg.data));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "validity"), JSIConverter<std::shared_ptr<ArrayBuffer>>::toJSI(runtime, arg.validity));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "dtype"), JSIConverter<std::string>::toJSI(runtime, arg.dtype));
      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::shared_ptr<ArrayBuffer>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "data")))) return false;
      if (!JSIConverter<std::shared_ptr<ArrayBuffer>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "validity")))) return false;
      if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "dtype")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
