1 // This file was automatically generated by protocompiler
3 // Compiled from SecDbBackupRecoverySet.proto
5 #import "SecDbBackupBag.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
10 #import "SecDbBackupBagIdentity.h"
12 #if !__has_feature(objc_arc)
13 # 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.
16 @implementation SecDbBackupBag
18 - (BOOL)hasBagIdentity
20 return _bagIdentity != nil;
22 @synthesize bagIdentity = _bagIdentity;
25 return _keybag != nil;
27 @synthesize keybag = _keybag;
29 - (NSString *)description
31 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
34 - (NSDictionary *)dictionaryRepresentation
36 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
37 if (self->_bagIdentity)
39 [dict setObject:[_bagIdentity dictionaryRepresentation] forKey:@"bagIdentity"];
43 [dict setObject:self->_keybag forKey:@"keybag"];
48 BOOL SecDbBackupBagReadFrom(__unsafe_unretained SecDbBackupBag *self, __unsafe_unretained PBDataReader *reader) {
49 while (PBReaderHasMoreData(reader)) {
53 PBReaderReadTag32AndType(reader, &tag, &aType);
55 if (PBReaderHasError(reader))
58 if (aType == TYPE_END_GROUP) {
64 case 1 /* bagIdentity */:
66 SecDbBackupBagIdentity *new_bagIdentity = [[SecDbBackupBagIdentity alloc] init];
67 self->_bagIdentity = new_bagIdentity;
68 PBDataReaderMark mark_bagIdentity;
69 BOOL markError = !PBReaderPlaceMark(reader, &mark_bagIdentity);
74 BOOL inError = !SecDbBackupBagIdentityReadFrom(new_bagIdentity, reader);
79 PBReaderRecallMark(reader, &mark_bagIdentity);
84 NSData *new_keybag = PBReaderReadData(reader);
85 self->_keybag = new_keybag;
89 if (!PBReaderSkipValueWithTag(reader, tag, aType))
94 return !PBReaderHasError(reader);
97 - (BOOL)readFrom:(PBDataReader *)reader
99 return SecDbBackupBagReadFrom(self, reader);
101 - (void)writeTo:(PBDataWriter *)writer
105 if (self->_bagIdentity != nil)
107 PBDataWriterWriteSubmessage(writer, self->_bagIdentity, 1);
114 PBDataWriterWriteDataField(writer, self->_keybag, 2);
119 - (void)copyTo:(SecDbBackupBag *)other
123 other.bagIdentity = _bagIdentity;
127 other.keybag = _keybag;
131 - (id)copyWithZone:(NSZone *)zone
133 SecDbBackupBag *copy = [[[self class] allocWithZone:zone] init];
134 copy->_bagIdentity = [_bagIdentity copyWithZone:zone];
135 copy->_keybag = [_keybag copyWithZone:zone];
139 - (BOOL)isEqual:(id)object
141 SecDbBackupBag *other = (SecDbBackupBag *)object;
142 return [other isMemberOfClass:[self class]]
144 ((!self->_bagIdentity && !other->_bagIdentity) || [self->_bagIdentity isEqual:other->_bagIdentity])
146 ((!self->_keybag && !other->_keybag) || [self->_keybag isEqual:other->_keybag])
154 [self->_bagIdentity hash]
160 - (void)mergeFrom:(SecDbBackupBag *)other
162 if (self->_bagIdentity && other->_bagIdentity)
164 [self->_bagIdentity mergeFrom:other->_bagIdentity];
166 else if (!self->_bagIdentity && other->_bagIdentity)
168 [self setBagIdentity:other->_bagIdentity];
172 [self setKeybag:other->_keybag];