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

#import "DBAssortedIntegers+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 DBAssortedIntegers

- (id)initWithAssortedIntegers:(DBAssortedIntegers *)assortedIntegers
{
    if (self = [super init]) {
        _eight = assortedIntegers.eight;
        _sixteen = assortedIntegers.sixteen;
        _thirtytwo = assortedIntegers.thirtytwo;
        _sixtyfour = assortedIntegers.sixtyfour;
        if (assortedIntegers.oEight == nil) {
            _oEight = nil;
        } else {
            _oEight = assortedIntegers.oEight;
        }
        if (assortedIntegers.oSixteen == nil) {
            _oSixteen = nil;
        } else {
            _oSixteen = assortedIntegers.oSixteen;
        }
        if (assortedIntegers.oThirtytwo == nil) {
            _oThirtytwo = nil;
        } else {
            _oThirtytwo = assortedIntegers.oThirtytwo;
        }
        if (assortedIntegers.oSixtyfour == nil) {
            _oSixtyfour = nil;
        } else {
            _oSixtyfour = assortedIntegers.oSixtyfour;
        }
    }
    return self;
}

- (id)initWithEight:(int8_t)eight sixteen:(int16_t)sixteen thirtytwo:(int32_t)thirtytwo sixtyfour:(int64_t)sixtyfour oEight:(NSNumber *)oEight oSixteen:(NSNumber *)oSixteen oThirtytwo:(NSNumber *)oThirtytwo oSixtyfour:(NSNumber *)oSixtyfour
{
    if (self = [super init]) {
        _eight = eight;
        _sixteen = sixteen;
        _thirtytwo = thirtytwo;
        _sixtyfour = sixtyfour;
        _oEight = oEight;
        _oSixteen = oSixteen;
        _oThirtytwo = oThirtytwo;
        _oSixtyfour = oSixtyfour;
    }
    return self;
}

- (id)initWithCppAssortedIntegers:(const AssortedIntegers &)assortedIntegers
{
    if (self = [super init]) {
        _eight = assortedIntegers.eight;
        _sixteen = assortedIntegers.sixteen;
        _thirtytwo = assortedIntegers.thirtytwo;
        _sixtyfour = assortedIntegers.sixtyfour;
        if (assortedIntegers.o_eight) {
            _oEight = [NSNumber numberWithChar:(*(assortedIntegers.o_eight))];
        } else {
            _oEight = nil;
        }
        if (assortedIntegers.o_sixteen) {
            _oSixteen = [NSNumber numberWithShort:(*(assortedIntegers.o_sixteen))];
        } else {
            _oSixteen = nil;
        }
        if (assortedIntegers.o_thirtytwo) {
            _oThirtytwo = [NSNumber numberWithInt:(*(assortedIntegers.o_thirtytwo))];
        } else {
            _oThirtytwo = nil;
        }
        if (assortedIntegers.o_sixtyfour) {
            _oSixtyfour = [NSNumber numberWithLongLong:(*(assortedIntegers.o_sixtyfour))];
        } else {
            _oSixtyfour = nil;
        }
    }
    return self;
}

- (AssortedIntegers)cppAssortedIntegers
{
    int8_t eight = _eight;
    int16_t sixteen = _sixteen;
    int32_t thirtytwo = _thirtytwo;
    int64_t sixtyfour = _sixtyfour;
    std::experimental::optional<int8_t> oEight;
    if (_oEight != nil) {
        int8_t optValue = [_oEight charValue];
        oEight = optValue;
    }
    std::experimental::optional<int16_t> oSixteen;
    if (_oSixteen != nil) {
        int16_t optValue = [_oSixteen shortValue];
        oSixteen = optValue;
    }
    std::experimental::optional<int32_t> oThirtytwo;
    if (_oThirtytwo != nil) {
        int32_t optValue = [_oThirtytwo intValue];
        oThirtytwo = optValue;
    }
    std::experimental::optional<int64_t> oSixtyfour;
    if (_oSixtyfour != nil) {
        int64_t optValue = [_oSixtyfour longLongValue];
        oSixtyfour = optValue;
    }
    return AssortedIntegers(
            std::move(eight),
            std::move(sixteen),
            std::move(thirtytwo),
            std::move(sixtyfour),
            std::move(oEight),
            std::move(oSixteen),
            std::move(oThirtytwo),
            std::move(oSixtyfour));
}
- (BOOL)isEqual:(id)other
{
    if (![other isKindOfClass:[DBAssortedIntegers class]]) {
        return NO;
    }
    DBAssortedIntegers *typedOther = (DBAssortedIntegers *)other;
    return self.eight == typedOther.eight &&
            self.sixteen == typedOther.sixteen &&
            self.thirtytwo == typedOther.thirtytwo &&
            self.sixtyfour == typedOther.sixtyfour &&
            ((self.oEight == nil && typedOther.oEight == nil) || (self.oEight != nil && [self.oEight isEqual:typedOther.oEight])) &&
            ((self.oSixteen == nil && typedOther.oSixteen == nil) || (self.oSixteen != nil && [self.oSixteen isEqual:typedOther.oSixteen])) &&
            ((self.oThirtytwo == nil && typedOther.oThirtytwo == nil) || (self.oThirtytwo != nil && [self.oThirtytwo isEqual:typedOther.oThirtytwo])) &&
            ((self.oSixtyfour == nil && typedOther.oSixtyfour == nil) || (self.oSixtyfour != nil && [self.oSixtyfour isEqual:typedOther.oSixtyfour]));
}

@end
