// This file was automatically generated by protocompiler
// DO NOT EDIT!
// Compiled from foo.proto

#import "SecDbKeychainSerializedItemV7.h"
#import <ProtocolBuffer/PBConstants.h>
#import <ProtocolBuffer/PBHashUtil.h>
#import <ProtocolBuffer/PBDataReader.h>

#if !__has_feature(objc_arc)
# error This generated file depends on ARC but it is not enabled; turn on ARC, or use 'objc_use_arc' option to generate non-ARC code.
#endif

@implementation SecDbKeychainSerializedItemV7

@synthesize encryptedSecretData = _encryptedSecretData;
@synthesize encryptedMetadata = _encryptedMetadata;
@synthesize keyclass = _keyclass;
- (NSString *)keyclassAsString:(SecDbKeychainSerializedItemV7_Keyclass)value
{
    return SecDbKeychainSerializedItemV7_KeyclassAsString(value);
}
- (SecDbKeychainSerializedItemV7_Keyclass)StringAsKeyclass:(NSString *)str
{
    return StringAsSecDbKeychainSerializedItemV7_Keyclass(str);
}

- (NSString *)description
{
    return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
}

- (NSDictionary *)dictionaryRepresentation
{
    NSMutableDictionary *dict = [NSMutableDictionary dictionary];
    if (self->_encryptedSecretData)
    {
        [dict setObject:self->_encryptedSecretData forKey:@"encryptedSecretData"];
    }
    if (self->_encryptedMetadata)
    {
        [dict setObject:self->_encryptedMetadata forKey:@"encryptedMetadata"];
    }
    [dict setObject:SecDbKeychainSerializedItemV7_KeyclassAsString(self->_keyclass) forKey:@"keyclass"];
    return dict;
}

BOOL SecDbKeychainSerializedItemV7ReadFrom(__unsafe_unretained SecDbKeychainSerializedItemV7 *self, __unsafe_unretained PBDataReader *reader) {
    while (PBReaderHasMoreData(reader)) {
        uint32_t tag = 0;
        uint8_t aType = 0;

        PBReaderReadTag32AndType(reader, &tag, &aType);

        if (PBReaderHasError(reader))
            break;

        if (aType == TYPE_END_GROUP) {
            break;
        }

        switch (tag) {

            case 1 /* encryptedSecretData */:
            {
                NSData *new_encryptedSecretData = PBReaderReadData(reader);
                self->_encryptedSecretData = new_encryptedSecretData;
            }
            break;
            case 2 /* encryptedMetadata */:
            {
                NSData *new_encryptedMetadata = PBReaderReadData(reader);
                self->_encryptedMetadata = new_encryptedMetadata;
            }
            break;
            case 3 /* keyclass */:
            {
                self->_keyclass = PBReaderReadInt32(reader);
            }
            break;
            default:
                if (!PBReaderSkipValueWithTag(reader, tag, aType))
                    return NO;
                break;
        }
    }
    return !PBReaderHasError(reader);
}

- (BOOL)readFrom:(PBDataReader *)reader
{
    return SecDbKeychainSerializedItemV7ReadFrom(self, reader);
}
- (void)writeTo:(PBDataWriter *)writer
{
    /* encryptedSecretData */
    {
        assert(nil != self->_encryptedSecretData);
        PBDataWriterWriteDataField(writer, self->_encryptedSecretData, 1);
    }
    /* encryptedMetadata */
    {
        assert(nil != self->_encryptedMetadata);
        PBDataWriterWriteDataField(writer, self->_encryptedMetadata, 2);
    }
    /* keyclass */
    {
        PBDataWriterWriteInt32Field(writer, self->_keyclass, 3);
    }
}

- (void)copyTo:(SecDbKeychainSerializedItemV7 *)other
{
    other.encryptedSecretData = _encryptedSecretData;
    other.encryptedMetadata = _encryptedMetadata;
    other->_keyclass = _keyclass;
}

- (id)copyWithZone:(NSZone *)zone
{
    SecDbKeychainSerializedItemV7 *copy = [[[self class] allocWithZone:zone] init];
    copy->_encryptedSecretData = [_encryptedSecretData copyWithZone:zone];
    copy->_encryptedMetadata = [_encryptedMetadata copyWithZone:zone];
    copy->_keyclass = _keyclass;
    return copy;
}

- (BOOL)isEqual:(id)object
{
    SecDbKeychainSerializedItemV7 *other = (SecDbKeychainSerializedItemV7 *)object;
    return [other isMemberOfClass:[self class]]
    &&
    ((!self->_encryptedSecretData && !other->_encryptedSecretData) || [self->_encryptedSecretData isEqual:other->_encryptedSecretData])
    &&
    ((!self->_encryptedMetadata && !other->_encryptedMetadata) || [self->_encryptedMetadata isEqual:other->_encryptedMetadata])
    &&
    self->_keyclass == other->_keyclass
    ;
}

- (NSUInteger)hash
{
    return 0
    ^
    [self->_encryptedSecretData hash]
    ^
    [self->_encryptedMetadata hash]
    ^
    PBHashInt((NSUInteger)_keyclass)
    ;
}

- (void)mergeFrom:(SecDbKeychainSerializedItemV7 *)other
{
    if (other->_encryptedSecretData)
    {
        [self setEncryptedSecretData:other->_encryptedSecretData];
    }
    if (other->_encryptedMetadata)
    {
        [self setEncryptedMetadata:other->_encryptedMetadata];
    }
    self->_keyclass = other->_keyclass;
}

@end

