1 // This file was automatically generated by protocompiler
3 // Compiled from OTPairingMessage.proto
5 #import "OTPairingMessage.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
10 #import "OTApplicantToSponsorRound2M1.h"
11 #import "OTSponsorToApplicantRound1M2.h"
12 #import "OTSponsorToApplicantRound2M2.h"
13 #import "OTSupportOctagonMessage.h"
14 #import "OTSupportSOSMessage.h"
16 #if !__has_feature(objc_arc)
17 # 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.
20 @implementation OTPairingMessage
26 @synthesize epoch = _epoch;
29 return _prepare != nil;
31 @synthesize prepare = _prepare;
34 return _voucher != nil;
36 @synthesize voucher = _voucher;
37 - (BOOL)hasSupportsOctagon
39 return _supportsOctagon != nil;
41 @synthesize supportsOctagon = _supportsOctagon;
42 - (BOOL)hasSupportsSOS
44 return _supportsSOS != nil;
46 @synthesize supportsSOS = _supportsSOS;
48 - (NSString *)description
50 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
53 - (NSDictionary *)dictionaryRepresentation
55 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
58 [dict setObject:[_epoch dictionaryRepresentation] forKey:@"epoch"];
62 [dict setObject:[_prepare dictionaryRepresentation] forKey:@"prepare"];
66 [dict setObject:[_voucher dictionaryRepresentation] forKey:@"voucher"];
68 if (self->_supportsOctagon)
70 [dict setObject:[_supportsOctagon dictionaryRepresentation] forKey:@"supportsOctagon"];
72 if (self->_supportsSOS)
74 [dict setObject:[_supportsSOS dictionaryRepresentation] forKey:@"supportsSOS"];
79 BOOL OTPairingMessageReadFrom(__unsafe_unretained OTPairingMessage *self, __unsafe_unretained PBDataReader *reader) {
80 while (PBReaderHasMoreData(reader)) {
84 PBReaderReadTag32AndType(reader, &tag, &aType);
86 if (PBReaderHasError(reader))
89 if (aType == TYPE_END_GROUP) {
97 OTSponsorToApplicantRound1M2 *new_epoch = [[OTSponsorToApplicantRound1M2 alloc] init];
98 self->_epoch = new_epoch;
99 PBDataReaderMark mark_epoch;
100 BOOL markError = !PBReaderPlaceMark(reader, &mark_epoch);
105 BOOL inError = !OTSponsorToApplicantRound1M2ReadFrom(new_epoch, reader);
110 PBReaderRecallMark(reader, &mark_epoch);
113 case 2 /* prepare */:
115 OTApplicantToSponsorRound2M1 *new_prepare = [[OTApplicantToSponsorRound2M1 alloc] init];
116 self->_prepare = new_prepare;
117 PBDataReaderMark mark_prepare;
118 BOOL markError = !PBReaderPlaceMark(reader, &mark_prepare);
123 BOOL inError = !OTApplicantToSponsorRound2M1ReadFrom(new_prepare, reader);
128 PBReaderRecallMark(reader, &mark_prepare);
131 case 3 /* voucher */:
133 OTSponsorToApplicantRound2M2 *new_voucher = [[OTSponsorToApplicantRound2M2 alloc] init];
134 self->_voucher = new_voucher;
135 PBDataReaderMark mark_voucher;
136 BOOL markError = !PBReaderPlaceMark(reader, &mark_voucher);
141 BOOL inError = !OTSponsorToApplicantRound2M2ReadFrom(new_voucher, reader);
146 PBReaderRecallMark(reader, &mark_voucher);
149 case 5 /* supportsOctagon */:
151 OTSupportOctagonMessage *new_supportsOctagon = [[OTSupportOctagonMessage alloc] init];
152 self->_supportsOctagon = new_supportsOctagon;
153 PBDataReaderMark mark_supportsOctagon;
154 BOOL markError = !PBReaderPlaceMark(reader, &mark_supportsOctagon);
159 BOOL inError = !OTSupportOctagonMessageReadFrom(new_supportsOctagon, reader);
164 PBReaderRecallMark(reader, &mark_supportsOctagon);
167 case 6 /* supportsSOS */:
169 OTSupportSOSMessage *new_supportsSOS = [[OTSupportSOSMessage alloc] init];
170 self->_supportsSOS = new_supportsSOS;
171 PBDataReaderMark mark_supportsSOS;
172 BOOL markError = !PBReaderPlaceMark(reader, &mark_supportsSOS);
177 BOOL inError = !OTSupportSOSMessageReadFrom(new_supportsSOS, reader);
182 PBReaderRecallMark(reader, &mark_supportsSOS);
186 if (!PBReaderSkipValueWithTag(reader, tag, aType))
191 return !PBReaderHasError(reader);
194 - (BOOL)readFrom:(PBDataReader *)reader
196 return OTPairingMessageReadFrom(self, reader);
198 - (void)writeTo:(PBDataWriter *)writer
202 if (self->_epoch != nil)
204 PBDataWriterWriteSubmessage(writer, self->_epoch, 1);
209 if (self->_prepare != nil)
211 PBDataWriterWriteSubmessage(writer, self->_prepare, 2);
216 if (self->_voucher != nil)
218 PBDataWriterWriteSubmessage(writer, self->_voucher, 3);
221 /* supportsOctagon */
223 if (self->_supportsOctagon != nil)
225 PBDataWriterWriteSubmessage(writer, self->_supportsOctagon, 5);
230 if (self->_supportsSOS != nil)
232 PBDataWriterWriteSubmessage(writer, self->_supportsSOS, 6);
237 - (void)copyTo:(OTPairingMessage *)other
241 other.epoch = _epoch;
245 other.prepare = _prepare;
249 other.voucher = _voucher;
251 if (_supportsOctagon)
253 other.supportsOctagon = _supportsOctagon;
257 other.supportsSOS = _supportsSOS;
261 - (id)copyWithZone:(NSZone *)zone
263 OTPairingMessage *copy = [[[self class] allocWithZone:zone] init];
264 copy->_epoch = [_epoch copyWithZone:zone];
265 copy->_prepare = [_prepare copyWithZone:zone];
266 copy->_voucher = [_voucher copyWithZone:zone];
267 copy->_supportsOctagon = [_supportsOctagon copyWithZone:zone];
268 copy->_supportsSOS = [_supportsSOS copyWithZone:zone];
272 - (BOOL)isEqual:(id)object
274 OTPairingMessage *other = (OTPairingMessage *)object;
275 return [other isMemberOfClass:[self class]]
277 ((!self->_epoch && !other->_epoch) || [self->_epoch isEqual:other->_epoch])
279 ((!self->_prepare && !other->_prepare) || [self->_prepare isEqual:other->_prepare])
281 ((!self->_voucher && !other->_voucher) || [self->_voucher isEqual:other->_voucher])
283 ((!self->_supportsOctagon && !other->_supportsOctagon) || [self->_supportsOctagon isEqual:other->_supportsOctagon])
285 ((!self->_supportsSOS && !other->_supportsSOS) || [self->_supportsSOS isEqual:other->_supportsSOS])
295 [self->_prepare hash]
297 [self->_voucher hash]
299 [self->_supportsOctagon hash]
301 [self->_supportsSOS hash]
305 - (void)mergeFrom:(OTPairingMessage *)other
307 if (self->_epoch && other->_epoch)
309 [self->_epoch mergeFrom:other->_epoch];
311 else if (!self->_epoch && other->_epoch)
313 [self setEpoch:other->_epoch];
315 if (self->_prepare && other->_prepare)
317 [self->_prepare mergeFrom:other->_prepare];
319 else if (!self->_prepare && other->_prepare)
321 [self setPrepare:other->_prepare];
323 if (self->_voucher && other->_voucher)
325 [self->_voucher mergeFrom:other->_voucher];
327 else if (!self->_voucher && other->_voucher)
329 [self setVoucher:other->_voucher];
331 if (self->_supportsOctagon && other->_supportsOctagon)
333 [self->_supportsOctagon mergeFrom:other->_supportsOctagon];
335 else if (!self->_supportsOctagon && other->_supportsOctagon)
337 [self setSupportsOctagon:other->_supportsOctagon];
339 if (self->_supportsSOS && other->_supportsSOS)
341 [self->_supportsSOS mergeFrom:other->_supportsSOS];
343 else if (!self->_supportsSOS && other->_supportsSOS)
345 [self setSupportsSOS:other->_supportsSOS];