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

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

namespace djinni_generated {

auto MapListRecord::toCpp(ObjcType obj) -> CppType
{
    assert(obj);
    std::vector<std::unordered_map<std::string, int64_t>> map_list;
    map_list.reserve([obj.mapList count]);
    for (NSDictionary *objcValue_0 in obj.mapList) {
        std::unordered_map<std::string, int64_t> cppValue_0;
        for (id objcKey_1 in objcValue_0) {
            std::string cppKey_1 = ::djinni::String::toCpp(objcKey_1);
            int64_t cppValue_1 = ::djinni::I64::Boxed::toCpp([objcValue_0 objectForKey:objcKey_1]);
            cppValue_0.emplace(std::move(cppKey_1), std::move(cppValue_1));
        }
        map_list.push_back(std::move(cppValue_0));
    }
    return ::MapListRecord(
        map_list);
}

auto MapListRecord::fromCpp(const CppType& cpp) -> ObjcType
{
    std::vector<NSDictionary *> mapListTempVector;
    mapListTempVector.reserve(cpp.map_list.size());
    for (const auto & cppValue_0 : cpp.map_list) {
        std::vector<NSString *> objcValue_0TempKeyVector;
        objcValue_0TempKeyVector.reserve(cppValue_0.size());
        std::vector<NSNumber *> objcValue_0TempValueVector;
        objcValue_0TempValueVector.reserve(cppValue_0.size());
        for (const auto & cppPair_1 : cppValue_0) {
            NSString *objcKey_1 = ::djinni::String::fromCpp(cppPair_1.first);
            NSNumber *objcValue_1 = ::djinni::I64::Boxed::fromCpp(cppPair_1.second);
            objcValue_0TempKeyVector.push_back(objcKey_1);
            objcValue_0TempValueVector.push_back(objcValue_1);
        }
        NSDictionary *objcValue_0 = [NSDictionary dictionaryWithObjects:&objcValue_0TempValueVector[0] forKeys:&objcValue_0TempKeyVector[0] count:cppValue_0.size()];
        mapListTempVector.push_back(objcValue_0);
    }
    NSArray *mapList = [NSArray arrayWithObjects:&mapListTempVector[0] count:mapListTempVector.size()];
    return [[DBMapListRecord alloc]
        initWithMapList:mapList];
}

}  // namespace djinni_generated
