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

#import "DBClass1+Private.h"
#import "DBClass1.h"
#import "DBClass1+Private.h"
#import "DBInnerClass+Private.h"
#import "DJICppWrapperCache+Private.h"
#import "DJIError.h"
#import "DJIMarshal+Private.h"
#import "djinni-packages/package2/generated-src/objc/DBClass2+Private.h"
#include <exception>
#include <stdexcept>
#include <utility>

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

@interface DBClass1 ()

- (id)initWithCpp:(const std::shared_ptr<::package1::Class1>&)cppRef;

@end

@implementation DBClass1 {
    ::djinni::CppProxyCache::Handle<std::shared_ptr<::package1::Class1>> _cppRefHandle;
}

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

- (nonnull NSString *)getName {
    try {
        auto r = _cppRefHandle.get()->get_name();
        return ::djinni::String::fromCpp(r);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

- (nonnull NSString *)getInnerClassName {
    try {
        auto r = _cppRefHandle.get()->get_inner_class_name();
        return ::djinni::String::fromCpp(r);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

- (nullable DBClass2 *)getClass2 {
    try {
        auto r = _cppRefHandle.get()->get_class2();
        return ::djinni_generated::Class2::fromCpp(r);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

+ (nullable DBClass1 *)createWithInnerClass:(nullable id<DBInnerClass>)innerClass {
    try {
        auto r = ::package1::Class1::create_with_inner_class(::djinni_generated::InnerClass::toCpp(innerClass));
        return ::djinni_generated::Class1::fromCpp(r);
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

namespace djinni_generated {

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

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

}  // namespace djinni_generated

@end
