]> git.saurik.com Git - apple/security.git/blob - keychain/securityd/SecDbBackupManager-protobufs/generated_source/SecDbBackupBag.m
Security-59306.41.2.tar.gz
[apple/security.git] / keychain / securityd / SecDbBackupManager-protobufs / generated_source / SecDbBackupBag.m
1 // This file was automatically generated by protocompiler
2 // DO NOT EDIT!
3 // Compiled from SecDbBackupRecoverySet.proto
4
5 #import "SecDbBackupBag.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
9
10 #import "SecDbBackupBagIdentity.h"
11
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.
14 #endif
15
16 @implementation SecDbBackupBag
17
18 - (BOOL)hasBagIdentity
19 {
20 return _bagIdentity != nil;
21 }
22 @synthesize bagIdentity = _bagIdentity;
23 - (BOOL)hasKeybag
24 {
25 return _keybag != nil;
26 }
27 @synthesize keybag = _keybag;
28
29 - (NSString *)description
30 {
31 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
32 }
33
34 - (NSDictionary *)dictionaryRepresentation
35 {
36 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
37 if (self->_bagIdentity)
38 {
39 [dict setObject:[_bagIdentity dictionaryRepresentation] forKey:@"bagIdentity"];
40 }
41 if (self->_keybag)
42 {
43 [dict setObject:self->_keybag forKey:@"keybag"];
44 }
45 return dict;
46 }
47
48 BOOL SecDbBackupBagReadFrom(__unsafe_unretained SecDbBackupBag *self, __unsafe_unretained PBDataReader *reader) {
49 while (PBReaderHasMoreData(reader)) {
50 uint32_t tag = 0;
51 uint8_t aType = 0;
52
53 PBReaderReadTag32AndType(reader, &tag, &aType);
54
55 if (PBReaderHasError(reader))
56 break;
57
58 if (aType == TYPE_END_GROUP) {
59 break;
60 }
61
62 switch (tag) {
63
64 case 1 /* bagIdentity */:
65 {
66 SecDbBackupBagIdentity *new_bagIdentity = [[SecDbBackupBagIdentity alloc] init];
67 self->_bagIdentity = new_bagIdentity;
68 PBDataReaderMark mark_bagIdentity;
69 BOOL markError = !PBReaderPlaceMark(reader, &mark_bagIdentity);
70 if (markError)
71 {
72 return NO;
73 }
74 BOOL inError = !SecDbBackupBagIdentityReadFrom(new_bagIdentity, reader);
75 if (inError)
76 {
77 return NO;
78 }
79 PBReaderRecallMark(reader, &mark_bagIdentity);
80 }
81 break;
82 case 2 /* keybag */:
83 {
84 NSData *new_keybag = PBReaderReadData(reader);
85 self->_keybag = new_keybag;
86 }
87 break;
88 default:
89 if (!PBReaderSkipValueWithTag(reader, tag, aType))
90 return NO;
91 break;
92 }
93 }
94 return !PBReaderHasError(reader);
95 }
96
97 - (BOOL)readFrom:(PBDataReader *)reader
98 {
99 return SecDbBackupBagReadFrom(self, reader);
100 }
101 - (void)writeTo:(PBDataWriter *)writer
102 {
103 /* bagIdentity */
104 {
105 if (self->_bagIdentity != nil)
106 {
107 PBDataWriterWriteSubmessage(writer, self->_bagIdentity, 1);
108 }
109 }
110 /* keybag */
111 {
112 if (self->_keybag)
113 {
114 PBDataWriterWriteDataField(writer, self->_keybag, 2);
115 }
116 }
117 }
118
119 - (void)copyTo:(SecDbBackupBag *)other
120 {
121 if (_bagIdentity)
122 {
123 other.bagIdentity = _bagIdentity;
124 }
125 if (_keybag)
126 {
127 other.keybag = _keybag;
128 }
129 }
130
131 - (id)copyWithZone:(NSZone *)zone
132 {
133 SecDbBackupBag *copy = [[[self class] allocWithZone:zone] init];
134 copy->_bagIdentity = [_bagIdentity copyWithZone:zone];
135 copy->_keybag = [_keybag copyWithZone:zone];
136 return copy;
137 }
138
139 - (BOOL)isEqual:(id)object
140 {
141 SecDbBackupBag *other = (SecDbBackupBag *)object;
142 return [other isMemberOfClass:[self class]]
143 &&
144 ((!self->_bagIdentity && !other->_bagIdentity) || [self->_bagIdentity isEqual:other->_bagIdentity])
145 &&
146 ((!self->_keybag && !other->_keybag) || [self->_keybag isEqual:other->_keybag])
147 ;
148 }
149
150 - (NSUInteger)hash
151 {
152 return 0
153 ^
154 [self->_bagIdentity hash]
155 ^
156 [self->_keybag hash]
157 ;
158 }
159
160 - (void)mergeFrom:(SecDbBackupBag *)other
161 {
162 if (self->_bagIdentity && other->_bagIdentity)
163 {
164 [self->_bagIdentity mergeFrom:other->_bagIdentity];
165 }
166 else if (!self->_bagIdentity && other->_bagIdentity)
167 {
168 [self setBagIdentity:other->_bagIdentity];
169 }
170 if (other->_keybag)
171 {
172 [self setKeybag:other->_keybag];
173 }
174 }
175
176 @end
177