mirror of
https://github.com/zoriya/react-native-omni.git
synced 2026-08-05 21:58:54 +00:00
68 lines
2.4 KiB
C++
Generated
68 lines
2.4 KiB
C++
Generated
///
|
|
/// JCastStatus.hpp
|
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
/// https://github.com/mrousavy/nitro
|
|
/// Copyright © Marc Rousavy @ Margelo
|
|
///
|
|
|
|
#pragma once
|
|
|
|
#include <fbjni/fbjni.h>
|
|
#include "CastStatus.hpp"
|
|
|
|
namespace margelo::nitro::omni {
|
|
|
|
using namespace facebook;
|
|
|
|
/**
|
|
* The C++ JNI bridge between the C++ enum "CastStatus" and the Kotlin enum "CastStatus".
|
|
*/
|
|
struct JCastStatus final: public jni::JavaClass<JCastStatus> {
|
|
public:
|
|
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/omni/CastStatus;";
|
|
|
|
public:
|
|
/**
|
|
* Convert this Java/Kotlin-based enum to the C++ enum CastStatus.
|
|
*/
|
|
[[maybe_unused]]
|
|
[[nodiscard]]
|
|
CastStatus toCpp() const {
|
|
static const auto clazz = javaClassStatic();
|
|
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
return static_cast<CastStatus>(ordinal);
|
|
}
|
|
|
|
public:
|
|
/**
|
|
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
*/
|
|
[[maybe_unused]]
|
|
static jni::alias_ref<JCastStatus> fromCpp(CastStatus value) {
|
|
static const auto clazz = javaClassStatic();
|
|
switch (value) {
|
|
case CastStatus::CONNECTING:
|
|
static const auto fieldCONNECTING = clazz->getStaticField<JCastStatus>("CONNECTING");
|
|
return clazz->getStaticFieldValue(fieldCONNECTING);
|
|
case CastStatus::CONNECTED:
|
|
static const auto fieldCONNECTED = clazz->getStaticField<JCastStatus>("CONNECTED");
|
|
return clazz->getStaticFieldValue(fieldCONNECTED);
|
|
case CastStatus::AVAILABLE:
|
|
static const auto fieldAVAILABLE = clazz->getStaticField<JCastStatus>("AVAILABLE");
|
|
return clazz->getStaticFieldValue(fieldAVAILABLE);
|
|
case CastStatus::UNAVAILABLE:
|
|
static const auto fieldUNAVAILABLE = clazz->getStaticField<JCastStatus>("UNAVAILABLE");
|
|
return clazz->getStaticFieldValue(fieldUNAVAILABLE);
|
|
case CastStatus::UNSUPPORTED:
|
|
static const auto fieldUNSUPPORTED = clazz->getStaticField<JCastStatus>("UNSUPPORTED");
|
|
return clazz->getStaticFieldValue(fieldUNSUPPORTED);
|
|
default:
|
|
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
}
|
|
}
|
|
};
|
|
|
|
} // namespace margelo::nitro::omni
|