// AUTOGENERATED FILE - DO NOT MODIFY!
// This file generated by Djinni from enum_flags.djinni

#import "DBFlagRoundtrip+Private.h"
#import "DBFlagRoundtrip.h"
#import "DBAccessFlags+Private.h"
#import "DBEmptyFlags+Private.h"
#import "DJICppWrapperCache+Private.h"
#import "DJIError.h"
#import "DJIMarshal+Private.h"
#include <exception>
#include <stdexcept>
#include <utility>

static_assert(__has_feature(objc_arc), "Djinni requires ARC to be enabled for this file");

@interface DBFlagRoundtrip ()

- (id)initWithCpp:(const std::shared_ptr<::testsuite::FlagRoundtrip>&)cppRef;

@end

@implementation DBFlagRoundtrip {
    ::djinni::CppProxyCache::Handle<std::shared_ptr<::testsuite::FlagRoundtrip>> _cppRefHandle;
}

- (id)initWithCpp:(const std::shared_ptr<::testsuite::FlagRoundtrip>&)cppRef
{
    if (self = [super init]) {
        _cppRefHandle.assign(cppRef);
    }
    return self;
}

+ (DBAccessFlags)roundtripAccess:(DBAccessFlags)flag {
    try {
        auto objcpp_result_ = ::testsuite::FlagRoundtrip::roundtrip_access(::djinni::Enum<::testsuite::access_flags, DBAccessFlags>::toCpp(flag));
        return ::djinni::Enum<::testsuite::access_flags, DBAccessFlags>::fromCpp(objcpp_result_);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

+ (DBEmptyFlags)roundtripEmpty:(DBEmptyFlags)flag {
    try {
        auto objcpp_result_ = ::testsuite::FlagRoundtrip::roundtrip_empty(::djinni::Enum<::testsuite::empty_flags, DBEmptyFlags>::toCpp(flag));
        return ::djinni::Enum<::testsuite::empty_flags, DBEmptyFlags>::fromCpp(objcpp_result_);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

+ (nullable NSNumber *)roundtripAccessBoxed:(nullable NSNumber *)flag {
    try {
        auto objcpp_result_ = ::testsuite::FlagRoundtrip::roundtrip_access_boxed(::djinni::Optional<std::experimental::optional, ::djinni::Enum<::testsuite::access_flags, DBAccessFlags>>::toCpp(flag));
        return ::djinni::Optional<std::experimental::optional, ::djinni::Enum<::testsuite::access_flags, DBAccessFlags>>::fromCpp(objcpp_result_);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

+ (nullable NSNumber *)roundtripEmptyBoxed:(nullable NSNumber *)flag {
    try {
        auto objcpp_result_ = ::testsuite::FlagRoundtrip::roundtrip_empty_boxed(::djinni::Optional<std::experimental::optional, ::djinni::Enum<::testsuite::empty_flags, DBEmptyFlags>>::toCpp(flag));
        return ::djinni::Optional<std::experimental::optional, ::djinni::Enum<::testsuite::empty_flags, DBEmptyFlags>>::fromCpp(objcpp_result_);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

namespace djinni_generated {

auto FlagRoundtrip::toCpp(ObjcType objc) -> CppType
{
    if (!objc) {
        return nullptr;
    }
    return objc->_cppRefHandle.get();
}

auto FlagRoundtrip::fromCppOpt(const CppOptType& cpp) -> ObjcType
{
    if (!cpp) {
        return nil;
    }
    return ::djinni::get_cpp_proxy<DBFlagRoundtrip>(cpp);
}

}  // namespace djinni_generated

@end
