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"
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.
18 @implementation OTPairingMessage
24 @synthesize epoch = _epoch;
27 return _prepare != nil;
29 @synthesize prepare = _prepare;
32 return _voucher != nil;
34 @synthesize voucher = _voucher;
36 - (NSString *)description
38 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
41 - (NSDictionary *)dictionaryRepresentation
43 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
46 [dict setObject:[_epoch dictionaryRepresentation] forKey:@"epoch"];
50 [dict setObject:[_prepare dictionaryRepresentation] forKey:@"prepare"];
54 [dict setObject:[_voucher dictionaryRepresentation] forKey:@"voucher"];
59 BOOL OTPairingMessageReadFrom(__unsafe_unretained OTPairingMessage *self, __unsafe_unretained PBDataReader *reader) {
60 while (PBReaderHasMoreData(reader)) {
64 PBReaderReadTag32AndType(reader, &tag, &aType);
66 if (PBReaderHasError(reader))
69 if (aType == TYPE_END_GROUP) {
77 OTSponsorToApplicantRound1M2 *new_epoch = [[OTSponsorToApplicantRound1M2 alloc] init];
78 self->_epoch = new_epoch;
79 PBDataReaderMark mark_epoch;
80 BOOL markError = !PBReaderPlaceMark(reader, &mark_epoch);
85 BOOL inError = !OTSponsorToApplicantRound1M2ReadFrom(new_epoch, reader);
90 PBReaderRecallMark(reader, &mark_epoch);
95 OTApplicantToSponsorRound2M1 *new_prepare = [[OTApplicantToSponsorRound2M1 alloc] init];
96 self->_prepare = new_prepare;
97 PBDataReaderMark mark_prepare;
98 BOOL markError = !PBReaderPlaceMark(reader, &mark_prepare);
103 BOOL inError = !OTApplicantToSponsorRound2M1ReadFrom(new_prepare, reader);
108 PBReaderRecallMark(reader, &mark_prepare);
111 case 3 /* voucher */:
113 OTSponsorToApplicantRound2M2 *new_voucher = [[OTSponsorToApplicantRound2M2 alloc] init];
114 self->_voucher = new_voucher;
115 PBDataReaderMark mark_voucher;
116 BOOL markError = !PBReaderPlaceMark(reader, &mark_voucher);
121 BOOL inError = !OTSponsorToApplicantRound2M2ReadFrom(new_voucher, reader);
126 PBReaderRecallMark(reader, &mark_voucher);
130 if (!PBReaderSkipValueWithTag(reader, tag, aType))
135 return !PBReaderHasError(reader);
138 - (BOOL)readFrom:(PBDataReader *)reader
140 return OTPairingMessageReadFrom(self, reader);
142 - (void)writeTo:(PBDataWriter *)writer
146 if (self->_epoch != nil)
148 PBDataWriterWriteSubmessage(writer, self->_epoch, 1);
153 if (self->_prepare != nil)
155 PBDataWriterWriteSubmessage(writer, self->_prepare, 2);
160 if (self->_voucher != nil)
162 PBDataWriterWriteSubmessage(writer, self->_voucher, 3);
167 - (void)copyTo:(OTPairingMessage *)other
171 other.epoch = _epoch;
175 other.prepare = _prepare;
179 other.voucher = _voucher;
183 - (id)copyWithZone:(NSZone *)zone
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];
192 - (BOOL)isEqual:(id)object
194 OTPairingMessage *other = (OTPairingMessage *)object;
195 return [other isMemberOfClass:[self class]]
197 ((!self->_epoch && !other->_epoch) || [self->_epoch isEqual:other->_epoch])
199 ((!self->_prepare && !other->_prepare) || [self->_prepare isEqual:other->_prepare])
201 ((!self->_voucher && !other->_voucher) || [self->_voucher isEqual:other->_voucher])
211 [self->_prepare hash]
213 [self->_voucher hash]
217 - (void)mergeFrom:(OTPairingMessage *)other
219 if (self->_epoch && other->_epoch)
221 [self->_epoch mergeFrom:other->_epoch];
223 else if (!self->_epoch && other->_epoch)
225 [self setEpoch:other->_epoch];
227 if (self->_prepare && other->_prepare)
229 [self->_prepare mergeFrom:other->_prepare];
231 else if (!self->_prepare && other->_prepare)
233 [self setPrepare:other->_prepare];
235 if (self->_voucher && other->_voucher)
237 [self->_voucher mergeFrom:other->_voucher];
239 else if (!self->_voucher && other->_voucher)
241 [self setVoucher:other->_voucher];