Files
2026-07-24 12:30:43 +05:30

116 lines
6.6 KiB
C++
Generated

///
/// EpubNovel.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
// Forward declaration of `EpubChapter` to properly resolve imports.
namespace margelo::nitro::nitroepub { struct EpubChapter; }
#include <string>
#include <optional>
#include "EpubChapter.hpp"
#include <vector>
namespace margelo::nitro::nitroepub {
/**
* A struct which can be represented as a JavaScript object (EpubNovel).
*/
struct EpubNovel final {
public:
std::string name SWIFT_PRIVATE;
std::optional<std::string> cover SWIFT_PRIVATE;
std::optional<std::string> summary SWIFT_PRIVATE;
std::optional<std::string> author SWIFT_PRIVATE;
std::optional<std::string> artist SWIFT_PRIVATE;
std::vector<EpubChapter> chapters SWIFT_PRIVATE;
std::vector<std::string> cssPaths SWIFT_PRIVATE;
std::vector<std::string> imagePaths SWIFT_PRIVATE;
public:
EpubNovel() = default;
explicit EpubNovel(std::string name, std::optional<std::string> cover, std::optional<std::string> summary, std::optional<std::string> author, std::optional<std::string> artist, std::vector<EpubChapter> chapters, std::vector<std::string> cssPaths, std::vector<std::string> imagePaths): name(name), cover(cover), summary(summary), author(author), artist(artist), chapters(chapters), cssPaths(cssPaths), imagePaths(imagePaths) {}
public:
friend bool operator==(const EpubNovel& lhs, const EpubNovel& rhs) = default;
};
} // namespace margelo::nitro::nitroepub
namespace margelo::nitro {
// C++ EpubNovel <> JS EpubNovel (object)
template <>
struct JSIConverter<margelo::nitro::nitroepub::EpubNovel> final {
static inline margelo::nitro::nitroepub::EpubNovel fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
jsi::Object obj = arg.asObject(runtime);
return margelo::nitro::nitroepub::EpubNovel(
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cover"))),
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "summary"))),
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "author"))),
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artist"))),
JSIConverter<std::vector<margelo::nitro::nitroepub::EpubChapter>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "chapters"))),
JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cssPaths"))),
JSIConverter<std::vector<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "imagePaths")))
);
}
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroepub::EpubNovel& 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, "cover"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.cover));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "summary"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.summary));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "author"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.author));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "artist"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.artist));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "chapters"), JSIConverter<std::vector<margelo::nitro::nitroepub::EpubChapter>>::toJSI(runtime, arg.chapters));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "cssPaths"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.cssPaths));
obj.setProperty(runtime, PropNameIDCache::get(runtime, "imagePaths"), JSIConverter<std::vector<std::string>>::toJSI(runtime, arg.imagePaths));
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<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cover")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "summary")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "author")))) return false;
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "artist")))) return false;
if (!JSIConverter<std::vector<margelo::nitro::nitroepub::EpubChapter>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "chapters")))) return false;
if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cssPaths")))) return false;
if (!JSIConverter<std::vector<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "imagePaths")))) return false;
return true;
}
};
} // namespace margelo::nitro