]> git.saurik.com Git - apple/security.git/blob - keychain/ot/proto/generated_source/OTPairingMessage.m
Security-59306.101.1.tar.gz
[apple/security.git] / keychain / ot / proto / generated_source / OTPairingMessage.m
1 // This file was automatically generated by protocompiler
2 // DO NOT EDIT!
3 // Compiled from OTPairingMessage.proto
4
5 #import "OTPairingMessage.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
9
10 #import "OTApplicantToSponsorRound2M1.h"
11 #import "OTSponsorToApplicantRound1M2.h"
12 #import "OTSponsorToApplicantRound2M2.h"
13
14 #if !__has_feature(objc_arc)
15 # 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 #endif
17
18 @implementation OTPairingMessage
19
20 - (BOOL)hasEpoch
21 {
22 return _epoch != nil;
23 }
24 @synthesize epoch = _epoch;
25 - (BOOL)hasPrepare
26 {
27 return _prepare != nil;
28 }
29 @synthesize prepare = _prepare;
30 - (BOOL)hasVoucher
31 {
32 return _voucher != nil;
33 }
34 @synthesize voucher = _voucher;
35
36 - (NSString *)description
37 {
38 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
39 }
40
41 - (NSDictionary *)dictionaryRepresentation
42 {
43 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
44 if (self->_epoch)
45 {
46 [dict setObject:[_epoch dictionaryRepresentation] forKey:@"epoch"];
47 }
48 if (self->_prepare)
49 {
50 [dict setObject:[_prepare dictionaryRepresentation] forKey:@"prepare"];
51 }
52 if (self->_voucher)
53 {
54 [dict setObject:[_voucher dictionaryRepresentation] forKey:@"voucher"];
55 }
56 return dict;
57 }
58
59 BOOL OTPairingMessageReadFrom(__unsafe_unretained OTPairingMessage *self, __unsafe_unretained PBDataReader *reader) {
60 while (PBReaderHasMoreData(reader)) {
61 uint32_t tag = 0;
62 uint8_t aType = 0;
63
64 PBReaderReadTag32AndType(reader, &tag, &aType);
65
66 if (PBReaderHasError(reader))
67 break;
68
69 if (aType == TYPE_END_GROUP) {
70 break;
71 }
72
73 switch (tag) {
74
75 case 1 /* epoch */:
76 {
77 OTSponsorToApplicantRound1M2 *new_epoch = [[OTSponsorToApplicantRound1M2 alloc] init];
78 self->_epoch = new_epoch;
79 PBDataReaderMark mark_epoch;
80 BOOL markError = !PBReaderPlaceMark(reader, &mark_epoch);
81 if (markError)
82 {
83 return NO;
84 }
85 BOOL inError = !OTSponsorToApplicantRound1M2ReadFrom(new_epoch, reader);
86 if (inError)
87 {
88 return NO;
89 }
90 PBReaderRecallMark(reader, &mark_epoch);
91 }
92 break;
93 case 2 /* prepare */:
94 {
95 OTApplicantToSponsorRound2M1 *new_prepare = [[OTApplicantToSponsorRound2M1 alloc] init];
96 self->_prepare = new_prepare;
97 PBDataReaderMark mark_prepare;
98 BOOL markError = !PBReaderPlaceMark(reader, &mark_prepare);
99 if (markError)
100 {
101 return NO;
102 }
103 BOOL inError = !OTApplicantToSponsorRound2M1ReadFrom(new_prepare, reader);
104 if (inError)
105 {
106 return NO;
107 }
108 PBReaderRecallMark(reader, &mark_prepare);
109 }
110 break;
111 case 3 /* voucher */:
112 {
113 OTSponsorToApplicantRound2M2 *new_voucher = [[OTSponsorToApplicantRound2M2 alloc] init];
114 self->_voucher = new_voucher;
115 PBDataReaderMark mark_voucher;
116 BOOL markError = !PBReaderPlaceMark(reader, &mark_voucher);
117 if (markError)
118 {
119 return NO;
120 }
121 BOOL inError = !OTSponsorToApplicantRound2M2ReadFrom(new_voucher, reader);
122 if (inError)
123 {
124 return NO;
125 }
126 PBReaderRecallMark(reader, &mark_voucher);
127 }
128 break;
129 default:
130 if (!PBReaderSkipValueWithTag(reader, tag, aType))
131 return NO;
132 break;
133 }
134 }
135 return !PBReaderHasError(reader);
136 }
137
138 - (BOOL)readFrom:(PBDataReader *)reader
139 {
140 return OTPairingMessageReadFrom(self, reader);
141 }
142 - (void)writeTo:(PBDataWriter *)writer
143 {
144 /* epoch */
145 {
146 if (self->_epoch != nil)
147 {
148 PBDataWriterWriteSubmessage(writer, self->_epoch, 1);
149 }
150 }
151 /* prepare */
152 {
153 if (self->_prepare != nil)
154 {
155 PBDataWriterWriteSubmessage(writer, self->_prepare, 2);
156 }
157 }
158 /* voucher */
159 {
160 if (self->_voucher != nil)
161 {
162 PBDataWriterWriteSubmessage(writer, self->_voucher, 3);
163 }
164 }
165 }
166
167 - (void)copyTo:(OTPairingMessage *)other
168 {
169 if (_epoch)
170 {
171 other.epoch = _epoch;
172 }
173 if (_prepare)
174 {
175 other.prepare = _prepare;
176 }
177 if (_voucher)
178 {
179 other.voucher = _voucher;
180 }
181 }
182
183 - (id)copyWithZone:(NSZone *)zone
184 {
185 OTPairingMessage *copy = [[[self class] allocWithZone:zone] init];
186 copy->_epoch = [_epoch copyWithZone:zone];
187 copy->_prepare = [_prepare copyWithZone:zone];
188 copy->_voucher = [_voucher copyWithZone:zone];
189 return copy;
190 }
191
192 - (BOOL)isEqual:(id)object
193 {
194 OTPairingMessage *other = (OTPairingMessage *)object;
195 return [other isMemberOfClass:[self class]]
196 &&
197 ((!self->_epoch && !other->_epoch) || [self->_epoch isEqual:other->_epoch])
198 &&
199 ((!self->_prepare && !other->_prepare) || [self->_prepare isEqual:other->_prepare])
200 &&
201 ((!self->_voucher && !other->_voucher) || [self->_voucher isEqual:other->_voucher])
202 ;
203 }
204
205 - (NSUInteger)hash
206 {
207 return 0
208 ^
209 [self->_epoch hash]
210 ^
211 [self->_prepare hash]
212 ^
213 [self->_voucher hash]
214 ;
215 }
216
217 - (void)mergeFrom:(OTPairingMessage *)other
218 {
219 if (self->_epoch && other->_epoch)
220 {
221 [self->_epoch mergeFrom:other->_epoch];
222 }
223 else if (!self->_epoch && other->_epoch)
224 {
225 [self setEpoch:other->_epoch];
226 }
227 if (self->_prepare && other->_prepare)
228 {
229 [self->_prepare mergeFrom:other->_prepare];
230 }
231 else if (!self->_prepare && other->_prepare)
232 {
233 [self setPrepare:other->_prepare];
234 }
235 if (self->_voucher && other->_voucher)
236 {
237 [self->_voucher mergeFrom:other->_voucher];
238 }
239 else if (!self->_voucher && other->_voucher)
240 {
241 [self setVoucher:other->_voucher];
242 }
243 }
244
245 @end
246