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

#import "DBRecordWithDerivings+Private.h"
#import "DJIDate.h"
#import <Foundation/Foundation.h>
#include <utility>
#include <vector>

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

@implementation DBRecordWithDerivings

- (id)initWithRecordWithDerivings:(DBRecordWithDerivings *)recordWithDerivings
{
    if (self = [super init]) {
        _key1 = recordWithDerivings.key1;
        _key2 = [recordWithDerivings.key2 copy];
    }
    return self;
}

- (id)initWithKey1:(int32_t)key1 key2:(NSString *)key2
{
    if (self = [super init]) {
        _key1 = key1;
        _key2 = [key2 copy];
    }
    return self;
}

- (id)initWithCppRecordWithDerivings:(const RecordWithDerivings &)recordWithDerivings
{
    if (self = [super init]) {
        _key1 = recordWithDerivings.key1;
        _key2 = [[NSString alloc] initWithBytes:recordWithDerivings.key2.data()
                length:recordWithDerivings.key2.length()
                encoding:NSUTF8StringEncoding];
    }
    return self;
}

- (RecordWithDerivings)cppRecordWithDerivings
{
    int32_t key1 = _key1;
    std::string key2([_key2 UTF8String], [_key2 lengthOfBytesUsingEncoding:NSUTF8StringEncoding]);
    return RecordWithDerivings(
            std::move(key1),
            std::move(key2));
}
- (BOOL)isEqual:(id)other
{
    if (![other isKindOfClass:[DBRecordWithDerivings class]]) {
        return NO;
    }
    DBRecordWithDerivings *typedOther = (DBRecordWithDerivings *)other;
    return self.key1 == typedOther.key1 &&
            [self.key2 isEqualToString:typedOther.key2];
}
- (NSComparisonResult)compare:(DBRecordWithDerivings *)other
{
    NSComparisonResult tempResult;
    if (self.key1 < other.key1) {
        tempResult = NSOrderedAscending;
    } else if (self.key1 > other.key1) {
        tempResult = NSOrderedDescending;
    } else {
        tempResult = NSOrderedSame;
    }
    if (tempResult != NSOrderedSame) {
        return tempResult;
    }
    tempResult = [self.key2 compare:other.key2];
    if (tempResult != NSOrderedSame) {
        return tempResult;
    }
    return NSOrderedSame;
}

@end
