OTEscrowRecordMetadata.m   [plain text]

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

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

#import "OTEscrowRecordMetadataClientMetadata.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 OTEscrowRecordMetadata

- (BOOL)hasBackupKeybagDigest
{
return _backupKeybagDigest != nil;
}
@synthesize backupKeybagDigest = _backupKeybagDigest;
- (BOOL)hasClientMetadata
{
return _clientMetadata != nil;
}
@synthesize clientMetadata = _clientMetadata;
@synthesize secureBackupUsesMultipleIcscs = _secureBackupUsesMultipleIcscs;
- (void)setSecureBackupUsesMultipleIcscs:(uint64_t)v
{
_has.secureBackupUsesMultipleIcscs = YES;
_secureBackupUsesMultipleIcscs = v;
}
- (void)setHasSecureBackupUsesMultipleIcscs:(BOOL)f
{
_has.secureBackupUsesMultipleIcscs = f;
}
- (BOOL)hasSecureBackupUsesMultipleIcscs
{
return _has.secureBackupUsesMultipleIcscs != 0;
}
- (BOOL)hasBottleId
{
return _bottleId != nil;
}
@synthesize bottleId = _bottleId;
@synthesize secureBackupTimestamp = _secureBackupTimestamp;
- (void)setSecureBackupTimestamp:(uint64_t)v
{
_has.secureBackupTimestamp = YES;
_secureBackupTimestamp = v;
}
- (void)setHasSecureBackupTimestamp:(BOOL)f
{
_has.secureBackupTimestamp = f;
}
- (BOOL)hasSecureBackupTimestamp
{
return _has.secureBackupTimestamp != 0;
}
- (BOOL)hasEscrowedSpki
{
return _escrowedSpki != nil;
}
@synthesize escrowedSpki = _escrowedSpki;
- (BOOL)hasPeerInfo
{
return _peerInfo != nil;
}
@synthesize peerInfo = _peerInfo;
- (BOOL)hasBottleValidity
{
return _bottleValidity != nil;
}
@synthesize bottleValidity = _bottleValidity;
- (BOOL)hasSerial
{
return _serial != nil;
}
@synthesize serial = _serial;

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

- (NSDictionary *)dictionaryRepresentation
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
if (self->_backupKeybagDigest)
{
[dict setObject:self->_backupKeybagDigest forKey:@"backup_keybag_digest"];
}
if (self->_clientMetadata)
{
[dict setObject:[_clientMetadata dictionaryRepresentation] forKey:@"client_metadata"];
}
if (self->_has.secureBackupUsesMultipleIcscs)
{
[dict setObject:[NSNumber numberWithUnsignedLongLong:self->_secureBackupUsesMultipleIcscs] forKey:@"secure_backup_uses_multiple_icscs"];
}
if (self->_bottleId)
{
[dict setObject:self->_bottleId forKey:@"bottle_id"];
}
if (self->_has.secureBackupTimestamp)
{
[dict setObject:[NSNumber numberWithUnsignedLongLong:self->_secureBackupTimestamp] forKey:@"secure_backup_timestamp"];
}
if (self->_escrowedSpki)
{
[dict setObject:self->_escrowedSpki forKey:@"escrowed_spki"];
}
if (self->_peerInfo)
{
[dict setObject:self->_peerInfo forKey:@"peer_info"];
}
if (self->_bottleValidity)
{
[dict setObject:self->_bottleValidity forKey:@"bottle_validity"];
}
if (self->_serial)
{
[dict setObject:self->_serial forKey:@"serial"];
}
return dict;
}

BOOL OTEscrowRecordMetadataReadFrom(__unsafe_unretained OTEscrowRecordMetadata *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 /* backupKeybagDigest */:
{
NSData *new_backupKeybagDigest = PBReaderReadData(reader);
self->_backupKeybagDigest = new_backupKeybagDigest;
}
break;
case 2 /* clientMetadata */:
{
OTEscrowRecordMetadataClientMetadata *new_clientMetadata = [[OTEscrowRecordMetadataClientMetadata alloc] init];
self->_clientMetadata = new_clientMetadata;
PBDataReaderMark mark_clientMetadata;
BOOL markError = !PBReaderPlaceMark(reader, &mark_clientMetadata);
if (markError)
{
return NO;
}
BOOL inError = !OTEscrowRecordMetadataClientMetadataReadFrom(new_clientMetadata, reader);
if (inError)
{
return NO;
}
PBReaderRecallMark(reader, &mark_clientMetadata);
}
break;
case 3 /* secureBackupUsesMultipleIcscs */:
{
self->_has.secureBackupUsesMultipleIcscs = YES;
self->_secureBackupUsesMultipleIcscs = PBReaderReadUint64(reader);
}
break;
case 4 /* bottleId */:
{
NSString *new_bottleId = PBReaderReadString(reader);
self->_bottleId = new_bottleId;
}
break;
case 5 /* secureBackupTimestamp */:
{
self->_has.secureBackupTimestamp = YES;
self->_secureBackupTimestamp = PBReaderReadUint64(reader);
}
break;
case 6 /* escrowedSpki */:
{
NSData *new_escrowedSpki = PBReaderReadData(reader);
self->_escrowedSpki = new_escrowedSpki;
}
break;
case 7 /* peerInfo */:
{
NSData *new_peerInfo = PBReaderReadData(reader);
self->_peerInfo = new_peerInfo;
}
break;
case 8 /* bottleValidity */:
{
NSString *new_bottleValidity = PBReaderReadString(reader);
self->_bottleValidity = new_bottleValidity;
}
break;
case 9 /* serial */:
{
NSString *new_serial = PBReaderReadString(reader);
self->_serial = new_serial;
}
break;
default:
if (!PBReaderSkipValueWithTag(reader, tag, aType))
return NO;
break;
}
}
return !PBReaderHasError(reader);
}

- (BOOL)readFrom:(PBDataReader *)reader
{
return OTEscrowRecordMetadataReadFrom(self, reader);
}
- (void)writeTo:(PBDataWriter *)writer
{
/* backupKeybagDigest */
{
if (self->_backupKeybagDigest)
{
PBDataWriterWriteDataField(writer, self->_backupKeybagDigest, 1);
}
}
/* clientMetadata */
{
if (self->_clientMetadata != nil)
{
PBDataWriterWriteSubmessage(writer, self->_clientMetadata, 2);
}
}
/* secureBackupUsesMultipleIcscs */
{
if (self->_has.secureBackupUsesMultipleIcscs)
{
PBDataWriterWriteUint64Field(writer, self->_secureBackupUsesMultipleIcscs, 3);
}
}
/* bottleId */
{
if (self->_bottleId)
{
PBDataWriterWriteStringField(writer, self->_bottleId, 4);
}
}
/* secureBackupTimestamp */
{
if (self->_has.secureBackupTimestamp)
{
PBDataWriterWriteUint64Field(writer, self->_secureBackupTimestamp, 5);
}
}
/* escrowedSpki */
{
if (self->_escrowedSpki)
{
PBDataWriterWriteDataField(writer, self->_escrowedSpki, 6);
}
}
/* peerInfo */
{
if (self->_peerInfo)
{
PBDataWriterWriteDataField(writer, self->_peerInfo, 7);
}
}
/* bottleValidity */
{
if (self->_bottleValidity)
{
PBDataWriterWriteStringField(writer, self->_bottleValidity, 8);
}
}
/* serial */
{
if (self->_serial)
{
PBDataWriterWriteStringField(writer, self->_serial, 9);
}
}
}

- (void)copyTo:(OTEscrowRecordMetadata *)other
{
if (_backupKeybagDigest)
{
other.backupKeybagDigest = _backupKeybagDigest;
}
if (_clientMetadata)
{
other.clientMetadata = _clientMetadata;
}
if (self->_has.secureBackupUsesMultipleIcscs)
{
other->_secureBackupUsesMultipleIcscs = _secureBackupUsesMultipleIcscs;
other->_has.secureBackupUsesMultipleIcscs = YES;
}
if (_bottleId)
{
other.bottleId = _bottleId;
}
if (self->_has.secureBackupTimestamp)
{
other->_secureBackupTimestamp = _secureBackupTimestamp;
other->_has.secureBackupTimestamp = YES;
}
if (_escrowedSpki)
{
other.escrowedSpki = _escrowedSpki;
}
if (_peerInfo)
{
other.peerInfo = _peerInfo;
}
if (_bottleValidity)
{
other.bottleValidity = _bottleValidity;
}
if (_serial)
{
other.serial = _serial;
}
}

- (id)copyWithZone:(NSZone *)zone
{
OTEscrowRecordMetadata *copy = [[[self class] allocWithZone:zone] init];
copy->_backupKeybagDigest = [_backupKeybagDigest copyWithZone:zone];
copy->_clientMetadata = [_clientMetadata copyWithZone:zone];
if (self->_has.secureBackupUsesMultipleIcscs)
{
copy->_secureBackupUsesMultipleIcscs = _secureBackupUsesMultipleIcscs;
copy->_has.secureBackupUsesMultipleIcscs = YES;
}
copy->_bottleId = [_bottleId copyWithZone:zone];
if (self->_has.secureBackupTimestamp)
{
copy->_secureBackupTimestamp = _secureBackupTimestamp;
copy->_has.secureBackupTimestamp = YES;
}
copy->_escrowedSpki = [_escrowedSpki copyWithZone:zone];
copy->_peerInfo = [_peerInfo copyWithZone:zone];
copy->_bottleValidity = [_bottleValidity copyWithZone:zone];
copy->_serial = [_serial copyWithZone:zone];
return copy;
}

- (BOOL)isEqual:(id)object
{
OTEscrowRecordMetadata *other = (OTEscrowRecordMetadata *)object;
return [other isMemberOfClass:[self class]]
&&
((!self->_backupKeybagDigest && !other->_backupKeybagDigest) || [self->_backupKeybagDigest isEqual:other->_backupKeybagDigest])
&&
((!self->_clientMetadata && !other->_clientMetadata) || [self->_clientMetadata isEqual:other->_clientMetadata])
&&
((self->_has.secureBackupUsesMultipleIcscs && other->_has.secureBackupUsesMultipleIcscs && self->_secureBackupUsesMultipleIcscs == other->_secureBackupUsesMultipleIcscs) || (!self->_has.secureBackupUsesMultipleIcscs && !other->_has.secureBackupUsesMultipleIcscs))
&&
((!self->_bottleId && !other->_bottleId) || [self->_bottleId isEqual:other->_bottleId])
&&
((self->_has.secureBackupTimestamp && other->_has.secureBackupTimestamp && self->_secureBackupTimestamp == other->_secureBackupTimestamp) || (!self->_has.secureBackupTimestamp && !other->_has.secureBackupTimestamp))
&&
((!self->_escrowedSpki && !other->_escrowedSpki) || [self->_escrowedSpki isEqual:other->_escrowedSpki])
&&
((!self->_peerInfo && !other->_peerInfo) || [self->_peerInfo isEqual:other->_peerInfo])
&&
((!self->_bottleValidity && !other->_bottleValidity) || [self->_bottleValidity isEqual:other->_bottleValidity])
&&
((!self->_serial && !other->_serial) || [self->_serial isEqual:other->_serial])
;
}

- (NSUInteger)hash
{
return 0
^
[self->_backupKeybagDigest hash]
^
[self->_clientMetadata hash]
^
(self->_has.secureBackupUsesMultipleIcscs ? PBHashInt((NSUInteger)self->_secureBackupUsesMultipleIcscs) : 0)
^
[self->_bottleId hash]
^
(self->_has.secureBackupTimestamp ? PBHashInt((NSUInteger)self->_secureBackupTimestamp) : 0)
^
[self->_escrowedSpki hash]
^
[self->_peerInfo hash]
^
[self->_bottleValidity hash]
^
[self->_serial hash]
;
}

- (void)mergeFrom:(OTEscrowRecordMetadata *)other
{
if (other->_backupKeybagDigest)
{
[self setBackupKeybagDigest:other->_backupKeybagDigest];
}
if (self->_clientMetadata && other->_clientMetadata)
{
[self->_clientMetadata mergeFrom:other->_clientMetadata];
}
else if (!self->_clientMetadata && other->_clientMetadata)
{
[self setClientMetadata:other->_clientMetadata];
}
if (other->_has.secureBackupUsesMultipleIcscs)
{
self->_secureBackupUsesMultipleIcscs = other->_secureBackupUsesMultipleIcscs;
self->_has.secureBackupUsesMultipleIcscs = YES;
}
if (other->_bottleId)
{
[self setBottleId:other->_bottleId];
}
if (other->_has.secureBackupTimestamp)
{
self->_secureBackupTimestamp = other->_secureBackupTimestamp;
self->_has.secureBackupTimestamp = YES;
}
if (other->_escrowedSpki)
{
[self setEscrowedSpki:other->_escrowedSpki];
}
if (other->_peerInfo)
{
[self setPeerInfo:other->_peerInfo];
}
if (other->_bottleValidity)
{
[self setBottleValidity:other->_bottleValidity];
}
if (other->_serial)
{
[self setSerial:other->_serial];
}
}

@end