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

#import "DBEnumUsageInterface+Private.h"
#import "DBEnumUsageInterface.h"
#import "DBColor+Private.h"
#import "DJICppWrapperCache+Private.h"
#import "DJIError.h"
#import "DJIMarshal+Private.h"
#import "DJIObjcWrapperCache+Private.h"
#include <exception>
#include <stdexcept>
#include <utility>

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

@interface DBEnumUsageInterfaceCppProxy : NSObject<DBEnumUsageInterface>

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

@end

@implementation DBEnumUsageInterfaceCppProxy {
    ::djinni::CppProxyCache::Handle<std::shared_ptr<::testsuite::EnumUsageInterface>> _cppRefHandle;
}

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

- (DBColor)e:(DBColor)e {
    try {
        auto objcpp_result_ = _cppRefHandle.get()->e(::djinni::Enum<::testsuite::color, DBColor>::toCpp(e));
        return ::djinni::Enum<::testsuite::color, DBColor>::fromCpp(objcpp_result_);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

- (nullable NSNumber *)o:(nullable NSNumber *)o {
    try {
        auto objcpp_result_ = _cppRefHandle.get()->o(::djinni::Optional<std::experimental::optional, ::djinni::Enum<::testsuite::color, DBColor>>::toCpp(o));
        return ::djinni::Optional<std::experimental::optional, ::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(objcpp_result_);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

- (nonnull NSArray<NSNumber *> *)l:(nonnull NSArray<NSNumber *> *)l {
    try {
        auto objcpp_result_ = _cppRefHandle.get()->l(::djinni::List<::djinni::Enum<::testsuite::color, DBColor>>::toCpp(l));
        return ::djinni::List<::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(objcpp_result_);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

- (nonnull NSSet<NSNumber *> *)s:(nonnull NSSet<NSNumber *> *)s {
    try {
        auto objcpp_result_ = _cppRefHandle.get()->s(::djinni::Set<::djinni::Enum<::testsuite::color, DBColor>>::toCpp(s));
        return ::djinni::Set<::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(objcpp_result_);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

- (nonnull NSDictionary<NSNumber *, NSNumber *> *)m:(nonnull NSDictionary<NSNumber *, NSNumber *> *)m {
    try {
        auto objcpp_result_ = _cppRefHandle.get()->m(::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::Enum<::testsuite::color, DBColor>>::toCpp(m));
        return ::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(objcpp_result_);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

namespace djinni_generated {

class EnumUsageInterface::ObjcProxy final
: public ::testsuite::EnumUsageInterface
, public ::djinni::ObjcProxyCache::Handle<ObjcType>
{
public:
    using Handle::Handle;
    ::testsuite::color e(::testsuite::color c_e) override
    {
        @autoreleasepool {
            auto objcpp_result_ = [Handle::get() e:(::djinni::Enum<::testsuite::color, DBColor>::fromCpp(c_e))];
            return ::djinni::Enum<::testsuite::color, DBColor>::toCpp(objcpp_result_);
        }
    }
    std::experimental::optional<::testsuite::color> o(std::experimental::optional<::testsuite::color> c_o) override
    {
        @autoreleasepool {
            auto objcpp_result_ = [Handle::get() o:(::djinni::Optional<std::experimental::optional, ::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(c_o))];
            return ::djinni::Optional<std::experimental::optional, ::djinni::Enum<::testsuite::color, DBColor>>::toCpp(objcpp_result_);
        }
    }
    std::vector<::testsuite::color> l(const std::vector<::testsuite::color> & c_l) override
    {
        @autoreleasepool {
            auto objcpp_result_ = [Handle::get() l:(::djinni::List<::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(c_l))];
            return ::djinni::List<::djinni::Enum<::testsuite::color, DBColor>>::toCpp(objcpp_result_);
        }
    }
    std::unordered_set<::testsuite::color> s(const std::unordered_set<::testsuite::color> & c_s) override
    {
        @autoreleasepool {
            auto objcpp_result_ = [Handle::get() s:(::djinni::Set<::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(c_s))];
            return ::djinni::Set<::djinni::Enum<::testsuite::color, DBColor>>::toCpp(objcpp_result_);
        }
    }
    std::unordered_map<::testsuite::color, ::testsuite::color> m(const std::unordered_map<::testsuite::color, ::testsuite::color> & c_m) override
    {
        @autoreleasepool {
            auto objcpp_result_ = [Handle::get() m:(::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::Enum<::testsuite::color, DBColor>>::fromCpp(c_m))];
            return ::djinni::Map<::djinni::Enum<::testsuite::color, DBColor>, ::djinni::Enum<::testsuite::color, DBColor>>::toCpp(objcpp_result_);
        }
    }
};

}  // namespace djinni_generated

namespace djinni_generated {

auto EnumUsageInterface::toCpp(ObjcType objc) -> CppType
{
    if (!objc) {
        return nullptr;
    }
    if ([(id)objc isKindOfClass:[DBEnumUsageInterfaceCppProxy class]]) {
        return ((DBEnumUsageInterfaceCppProxy*)objc)->_cppRefHandle.get();
    }
    return ::djinni::get_objc_proxy<ObjcProxy>(objc);
}

auto EnumUsageInterface::fromCppOpt(const CppOptType& cpp) -> ObjcType
{
    if (!cpp) {
        return nil;
    }
    if (auto cppPtr = dynamic_cast<ObjcProxy*>(cpp.get())) {
        return cppPtr->Handle::get();
    }
    return ::djinni::get_cpp_proxy<DBEnumUsageInterfaceCppProxy>(cpp);
}

}  // namespace djinni_generated

@end
