///
/// FileInfo.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::one {

  /**
   * A struct which can be represented as a JavaScript object (FileInfo).
   */
  struct FileInfo final {
  public:
    std::string uri     SWIFT_PRIVATE;
    bool exists     SWIFT_PRIVATE;
    bool isDirectory     SWIFT_PRIVATE;
    std::optional<double> size     SWIFT_PRIVATE;
    std::optional<double> modifiedAt     SWIFT_PRIVATE;

  public:
    FileInfo() = default;
    explicit FileInfo(std::string uri, bool exists, bool isDirectory, std::optional<double> size, std::optional<double> modifiedAt): uri(uri), exists(exists), isDirectory(isDirectory), size(size), modifiedAt(modifiedAt) {}

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

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ FileInfo <> JS FileInfo (object)
  template <>
  struct JSIConverter<margelo::nitro::one::FileInfo> final {
    static inline margelo::nitro::one::FileInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::FileInfo(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "exists"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isDirectory"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "size"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modifiedAt")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::FileInfo& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "uri"), JSIConverter<std::string>::toJSI(runtime, arg.uri));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "exists"), JSIConverter<bool>::toJSI(runtime, arg.exists));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "isDirectory"), JSIConverter<bool>::toJSI(runtime, arg.isDirectory));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "size"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.size));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "modifiedAt"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.modifiedAt));
      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, "uri")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "exists")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "isDirectory")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "size")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "modifiedAt")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
