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 "OTSOSMessage.h"
12 #import "OTSponsorToApplicantRound1M2.h"
13 #import "OTSponsorToApplicantRound2M2.h"
15 #if !__has_feature(objc_arc)
16 # 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.
19 @implementation OTPairingMessage
25 @synthesize epoch = _epoch;
28 return _prepare != nil;
30 @synthesize prepare = _prepare;
33 return _voucher != nil;
35 @synthesize voucher = _voucher;
36 - (BOOL)hasSosPairingMessage
38 return _sosPairingMessage != nil;
40 @synthesize sosPairingMessage = _sosPairingMessage;
42 - (NSString *)description
44 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
47 - (NSDictionary *)dictionaryRepresentation
49 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
52 [dict setObject:[_epoch dictionaryRepresentation] forKey:@"epoch"];
56 [dict setObject:[_prepare dictionaryRepresentation] forKey:@"prepare"];
60 [dict setObject:[_voucher dictionaryRepresentation] forKey:@"voucher"];
62 if (self->_sosPairingMessage)
64 [dict setObject:[_sosPairingMessage dictionaryRepresentation] forKey:@"sosPairingMessage"];
69 BOOL OTPairingMessageReadFrom(__unsafe_unretained OTPairingMessage *self, __unsafe_unretained PBDataReader *reader) {
70 while (PBReaderHasMoreData(reader)) {
74 PBReaderReadTag32AndType(reader, &tag, &aType);
76 if (PBReaderHasError(reader))
79 if (aType == TYPE_END_GROUP) {
87 OTSponsorToApplicantRound1M2 *new_epoch = [[OTSponsorToApplicantRound1M2 alloc] init];
88 self->_epoch = new_epoch;
89 PBDataReaderMark mark_epoch;
90 BOOL markError = !PBReaderPlaceMark(reader, &mark_epoch);
95 BOOL inError = !OTSponsorToApplicantRound1M2ReadFrom(new_epoch, reader);
100 PBReaderRecallMark(reader, &mark_epoch);
103 case 2 /* prepare */:
105 OTApplicantToSponsorRound2M1 *new_prepare = [[OTApplicantToSponsorRound2M1 alloc] init];
106 self->_prepare = new_prepare;
107 PBDataReaderMark mark_prepare;
108 BOOL markError = !PBReaderPlaceMark(reader, &mark_prepare);
113 BOOL inError = !OTApplicantToSponsorRound2M1ReadFrom(new_prepare, reader);
118 PBReaderRecallMark(reader, &mark_prepare);
121 case 3 /* voucher */:
123 OTSponsorToApplicantRound2M2 *new_voucher = [[OTSponsorToApplicantRound2M2 alloc] init];
124 self->_voucher = new_voucher;
125 PBDataReaderMark mark_voucher;
126 BOOL markError = !PBReaderPlaceMark(reader, &mark_voucher);
131 BOOL inError = !OTSponsorToApplicantRound2M2ReadFrom(new_voucher, reader);
136 PBReaderRecallMark(reader, &mark_voucher);
139 case 4 /* sosPairingMessage */:
141 OTSOSMessage *new_sosPairingMessage = [[OTSOSMessage alloc] init];
142 self->_sosPairingMessage = new_sosPairingMessage;
143 PBDataReaderMark mark_sosPairingMessage;
144 BOOL markError = !PBReaderPlaceMark(reader, &mark_sosPairingMessage);
149 BOOL inError = !OTSOSMessageReadFrom(new_sosPairingMessage, reader);
154 PBReaderRecallMark(reader, &mark_sosPairingMessage);
158 if (!PBReaderSkipValueWithTag(reader, tag, aType))
163 return !PBReaderHasError(reader);
166 - (BOOL)readFrom:(PBDataReader *)reader
168 return OTPairingMessageReadFrom(self, reader);
170 - (void)writeTo:(PBDataWriter *)writer
174 if (self->_epoch != nil)
176 PBDataWriterWriteSubmessage(writer, self->_epoch, 1);
181 if (self->_prepare != nil)
183 PBDataWriterWriteSubmessage(writer, self->_prepare, 2);
188 if (self->_voucher != nil)
190 PBDataWriterWriteSubmessage(writer, self->_voucher, 3);
193 /* sosPairingMessage */
195 if (self->_sosPairingMessage != nil)
197 PBDataWriterWriteSubmessage(writer, self->_sosPairingMessage, 4);
202 - (void)copyTo:(OTPairingMessage *)other
206 other.epoch = _epoch;
210 other.prepare = _prepare;
214 other.voucher = _voucher;
216 if (_sosPairingMessage)
218 other.sosPairingMessage = _sosPairingMessage;
222 - (id)copyWithZone:(NSZone *)zone
224 OTPairingMessage *copy = [[[self class] allocWithZone:zone] init];
225 copy->_epoch = [_epoch copyWithZone:zone];
226 copy->_prepare = [_prepare copyWithZone:zone];
227 copy->_voucher = [_voucher copyWithZone:zone];
228 copy->_sosPairingMessage = [_sosPairingMessage copyWithZone:zone];
232 - (BOOL)isEqual:(id)object
234 OTPairingMessage *other = (OTPairingMessage *)object;
235 return [other isMemberOfClass:[self class]]
237 ((!self->_epoch && !other->_epoch) || [self->_epoch isEqual:other->_epoch])
239 ((!self->_prepare && !other->_prepare) || [self->_prepare isEqual:other->_prepare])
241 ((!self->_voucher && !other->_voucher) || [self->_voucher isEqual:other->_voucher])
243 ((!self->_sosPairingMessage && !other->_sosPairingMessage) || [self->_sosPairingMessage isEqual:other->_sosPairingMessage])
253 [self->_prepare hash]
255 [self->_voucher hash]
257 [self->_sosPairingMessage hash]
261 - (void)mergeFrom:(OTPairingMessage *)other
263 if (self->_epoch && other->_epoch)
265 [self->_epoch mergeFrom:other->_epoch];
267 else if (!self->_epoch && other->_epoch)
269 [self setEpoch:other->_epoch];
271 if (self->_prepare && other->_prepare)
273 [self->_prepare mergeFrom:other->_prepare];
275 else if (!self->_prepare && other->_prepare)
277 [self setPrepare:other->_prepare];
279 if (self->_voucher && other->_voucher)
281 [self->_voucher mergeFrom:other->_voucher];
283 else if (!self->_voucher && other->_voucher)
285 [self setVoucher:other->_voucher];
287 if (self->_sosPairingMessage && other->_sosPairingMessage)
289 [self->_sosPairingMessage mergeFrom:other->_sosPairingMessage];
291 else if (!self->_sosPairingMessage && other->_sosPairingMessage)
293 [self setSosPairingMessage:other->_sosPairingMessage];