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

#import "TXSSortItemsCppProxy+Private.h"
#import "DJIDate.h"
#import "DJIError.h"
#import "TXSItemList+Private.h"
#import "TXSSortItems.h"
#import "TXSSortItemsCppProxy+Private.h"
#import "TXSSortOrder.h"
#import "TXSSortOrderTranslator+Private.h"
#import "TXSTextboxListenerObjcProxy+Private.h"
#include <exception>
#include <utility>
#include <vector>

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

@interface TXSSortItemsCppProxy ()
@property (nonatomic, readonly) std::shared_ptr<djinni::DbxCppWrapperCache<::textsort::SortItems>> cache;
@end

@implementation TXSSortItemsCppProxy

- (id)initWithCpp:(const std::shared_ptr<::textsort::SortItems> &)cppRef cache:(const std::shared_ptr<djinni::DbxCppWrapperCache<::textsort::SortItems>> &)cache
{
    if (self = [super init]) {
        _cppRef = cppRef;
        _cache = cache;
    }
    return self;
}

- (void)dealloc
{
    _cache->remove(_cppRef);
}

+ (id)sortItemsWithCpp:(const std::shared_ptr<::textsort::SortItems> &)cppRef
{
    const auto & cache = djinni::DbxCppWrapperCache<::textsort::SortItems>::getInstance();
    return cache->get(cppRef, [&] (const std::shared_ptr<::textsort::SortItems> & p) { return [[TXSSortItemsCppProxy alloc] initWithCpp:p cache:cache]; });
}

- (void)sort:(TXSSortOrder)order items:(TXSItemList *)items {
    try {
        ::textsort::sort_order cppOrder = [TXSSortOrderTranslator objcSortOrderToCppSortOrder:order];
        ::textsort::ItemList cppItems = std::move([items cppItemList]);
        _cppRef->sort(std::move(cppOrder), std::move(cppItems));
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

+ (id <TXSSortItems>)createWithListener:(id <TXSTextboxListener>)listener {
    try {
        std::shared_ptr<::textsort::TextboxListener> cppListener = ::djinni_generated::TextboxListenerObjcProxy::textbox_listener_with_objc(listener);
        std::shared_ptr<::textsort::SortItems> cppRet = ::textsort::SortItems::create_with_listener(std::move(cppListener));
        id <TXSSortItems> objcRet = [TXSSortItemsCppProxy sortItemsWithCpp:cppRet];
        return objcRet;
    } DJINNI_TRANSLATE_EXCEPTIONS()
}

@end
