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

#import "DBNestedCollection+Private.h"
#import "DJIDate.h"
#import "DJIMarshal+Private.h"
#import <Foundation/Foundation.h>
#include <cassert>
#include <utility>
#include <vector>

namespace djinni_generated {

auto NestedCollection::toCpp(ObjcType obj) -> CppType
{
    assert(obj);
    std::vector<std::unordered_set<std::string>> set_list;
    set_list.reserve([obj.setList count]);
    for (NSSet *objcValue_0 in obj.setList) {
        std::unordered_set<std::string> cppValue_0;
        for (NSString *objcValue_1 in objcValue_0) {
            std::string cppValue_1 = ::djinni::String::toCpp(objcValue_1);
            cppValue_0.insert(std::move(cppValue_1));
        }
        set_list.push_back(std::move(cppValue_0));
    }
    return ::NestedCollection(
        set_list);
}

auto NestedCollection::fromCpp(const CppType& cpp) -> ObjcType
{
    std::vector<NSSet *> setListTempVector;
    setListTempVector.reserve(cpp.set_list.size());
    for (const auto & cppValue_0 : cpp.set_list) {
        std::vector<NSString *> objcValue_0TempVector;
        objcValue_0TempVector.reserve(cppValue_0.size());
        for (const auto & cppValue_1 : cppValue_0) {
            NSString *objcValue_1 = ::djinni::String::fromCpp(cppValue_1);
            objcValue_0TempVector.push_back(objcValue_1);
        }
        NSSet *objcValue_0 = [NSSet setWithObjects:&objcValue_0TempVector[0] count:objcValue_0TempVector.size()];
        setListTempVector.push_back(objcValue_0);
    }
    NSArray *setList = [NSArray arrayWithObjects:&setListTempVector[0] count:setListTempVector.size()];
    return [[DBNestedCollection alloc]
        initWithSetList:setList];
}

}  // namespace djinni_generated
