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

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

namespace djinni_generated {

auto MapDateRecord::toCpp(ObjcType obj) -> CppType
{
    assert(obj);
    std::unordered_map<std::string, std::chrono::system_clock::time_point> dates_by_id;
    for (id objcKey_0 in obj.datesById) {
        std::string cppKey_0 = ::djinni::String::toCpp(objcKey_0);
        std::chrono::system_clock::time_point cppValue_0 = ::djinni::convert_date([[obj.datesById objectForKey:objcKey_0] timeIntervalSince1970]);
        dates_by_id.emplace(std::move(cppKey_0), std::move(cppValue_0));
    }
    return ::MapDateRecord(
        dates_by_id);
}

auto MapDateRecord::fromCpp(const CppType& cpp) -> ObjcType
{
    std::vector<NSString *> datesByIdTempKeyVector;
    datesByIdTempKeyVector.reserve(cpp.dates_by_id.size());
    std::vector<NSDate *> datesByIdTempValueVector;
    datesByIdTempValueVector.reserve(cpp.dates_by_id.size());
    for (const auto & cppPair_0 : cpp.dates_by_id) {
        NSString *objcKey_0 = ::djinni::String::fromCpp(cppPair_0.first);
        NSDate *objcValue_0 = [NSDate dateWithTimeIntervalSince1970:
                std::chrono::duration_cast<std::chrono::duration<double>>(cppPair_0.second.time_since_epoch()).count()];
        datesByIdTempKeyVector.push_back(objcKey_0);
        datesByIdTempValueVector.push_back(objcValue_0);
    }
    NSDictionary *datesById = [NSDictionary dictionaryWithObjects:&datesByIdTempValueVector[0] forKeys:&datesByIdTempKeyVector[0] count:cpp.dates_by_id.size()];
    return [[DBMapDateRecord alloc]
        initWithDatesById:datesById];
}

}  // namespace djinni_generated
