Files
2025-10-24 12:31:06 +02:00

97 lines
4.5 KiB
C++
Generated

///
/// VideoOrientation.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 Marc Rousavy @ Margelo
///
#pragma once
#if __has_include(<NitroModules/NitroHash.hpp>)
#include <NitroModules/NitroHash.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#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
namespace margelo::nitro::video {
/**
* An enum which can be represented as a JavaScript union (VideoOrientation).
*/
enum class VideoOrientation {
PORTRAIT SWIFT_NAME(portrait) = 0,
LANDSCAPE SWIFT_NAME(landscape) = 1,
PORTRAIT_UPSIDE_DOWN SWIFT_NAME(portraitUpsideDown) = 2,
LANDSCAPE_LEFT SWIFT_NAME(landscapeLeft) = 3,
LANDSCAPE_RIGHT SWIFT_NAME(landscapeRight) = 4,
SQUARE SWIFT_NAME(square) = 5,
UNKNOWN SWIFT_NAME(unknown) = 6,
} CLOSED_ENUM;
} // namespace margelo::nitro::video
namespace margelo::nitro {
// C++ VideoOrientation <> JS VideoOrientation (union)
template <>
struct JSIConverter<margelo::nitro::video::VideoOrientation> final {
static inline margelo::nitro::video::VideoOrientation fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
switch (hashString(unionValue.c_str(), unionValue.size())) {
case hashString("portrait"): return margelo::nitro::video::VideoOrientation::PORTRAIT;
case hashString("landscape"): return margelo::nitro::video::VideoOrientation::LANDSCAPE;
case hashString("portrait-upside-down"): return margelo::nitro::video::VideoOrientation::PORTRAIT_UPSIDE_DOWN;
case hashString("landscape-left"): return margelo::nitro::video::VideoOrientation::LANDSCAPE_LEFT;
case hashString("landscape-right"): return margelo::nitro::video::VideoOrientation::LANDSCAPE_RIGHT;
case hashString("square"): return margelo::nitro::video::VideoOrientation::SQUARE;
case hashString("unknown"): return margelo::nitro::video::VideoOrientation::UNKNOWN;
default: [[unlikely]]
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum VideoOrientation - invalid value!");
}
}
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::video::VideoOrientation arg) {
switch (arg) {
case margelo::nitro::video::VideoOrientation::PORTRAIT: return JSIConverter<std::string>::toJSI(runtime, "portrait");
case margelo::nitro::video::VideoOrientation::LANDSCAPE: return JSIConverter<std::string>::toJSI(runtime, "landscape");
case margelo::nitro::video::VideoOrientation::PORTRAIT_UPSIDE_DOWN: return JSIConverter<std::string>::toJSI(runtime, "portrait-upside-down");
case margelo::nitro::video::VideoOrientation::LANDSCAPE_LEFT: return JSIConverter<std::string>::toJSI(runtime, "landscape-left");
case margelo::nitro::video::VideoOrientation::LANDSCAPE_RIGHT: return JSIConverter<std::string>::toJSI(runtime, "landscape-right");
case margelo::nitro::video::VideoOrientation::SQUARE: return JSIConverter<std::string>::toJSI(runtime, "square");
case margelo::nitro::video::VideoOrientation::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
default: [[unlikely]]
throw std::invalid_argument("Cannot convert VideoOrientation to JS - invalid value: "
+ std::to_string(static_cast<int>(arg)) + "!");
}
}
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
if (!value.isString()) {
return false;
}
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
switch (hashString(unionValue.c_str(), unionValue.size())) {
case hashString("portrait"):
case hashString("landscape"):
case hashString("portrait-upside-down"):
case hashString("landscape-left"):
case hashString("landscape-right"):
case hashString("square"):
case hashString("unknown"):
return true;
default:
return false;
}
}
};
} // namespace margelo::nitro