1 // This file was automatically generated by protocompiler
3 // Compiled from OTPairingMessage.proto
5 #import "OTSponsorToApplicantRound2M2.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
10 #if !__has_feature(objc_arc)
11 # 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 @implementation OTSponsorToApplicantRound2M2
18 return _voucher != nil;
20 @synthesize voucher = _voucher;
21 - (BOOL)hasVoucherSignature
23 return _voucherSignature != nil;
25 @synthesize voucherSignature = _voucherSignature;
26 @synthesize preapprovedKeys = _preapprovedKeys;
27 - (void)clearPreapprovedKeys
29 [_preapprovedKeys removeAllObjects];
31 - (void)addPreapprovedKeys:(NSData *)i
33 if (!_preapprovedKeys)
35 _preapprovedKeys = [[NSMutableArray alloc] init];
37 [_preapprovedKeys addObject:i];
39 - (NSUInteger)preapprovedKeysCount
41 return [_preapprovedKeys count];
43 - (NSData *)preapprovedKeysAtIndex:(NSUInteger)idx
45 return [_preapprovedKeys objectAtIndex:idx];
47 + (Class)preapprovedKeysType
49 return [NSData class];
52 - (NSString *)description
54 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
57 - (NSDictionary *)dictionaryRepresentation
59 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
62 [dict setObject:self->_voucher forKey:@"voucher"];
64 if (self->_voucherSignature)
66 [dict setObject:self->_voucherSignature forKey:@"voucherSignature"];
68 if (self->_preapprovedKeys)
70 [dict setObject:self->_preapprovedKeys forKey:@"preapprovedKeys"];
75 BOOL OTSponsorToApplicantRound2M2ReadFrom(__unsafe_unretained OTSponsorToApplicantRound2M2 *self, __unsafe_unretained PBDataReader *reader) {
76 while (PBReaderHasMoreData(reader)) {
80 PBReaderReadTag32AndType(reader, &tag, &aType);
82 if (PBReaderHasError(reader))
85 if (aType == TYPE_END_GROUP) {
93 NSData *new_voucher = PBReaderReadData(reader);
94 self->_voucher = new_voucher;
97 case 2 /* voucherSignature */:
99 NSData *new_voucherSignature = PBReaderReadData(reader);
100 self->_voucherSignature = new_voucherSignature;
103 case 3 /* preapprovedKeys */:
105 NSData *new_preapprovedKeys = PBReaderReadData(reader);
106 if (new_preapprovedKeys)
108 [self addPreapprovedKeys:new_preapprovedKeys];
113 if (!PBReaderSkipValueWithTag(reader, tag, aType))
118 return !PBReaderHasError(reader);
121 - (BOOL)readFrom:(PBDataReader *)reader
123 return OTSponsorToApplicantRound2M2ReadFrom(self, reader);
125 - (void)writeTo:(PBDataWriter *)writer
131 PBDataWriterWriteDataField(writer, self->_voucher, 1);
134 /* voucherSignature */
136 if (self->_voucherSignature)
138 PBDataWriterWriteDataField(writer, self->_voucherSignature, 2);
141 /* preapprovedKeys */
143 for (NSData *s_preapprovedKeys in self->_preapprovedKeys)
145 PBDataWriterWriteDataField(writer, s_preapprovedKeys, 3);
150 - (void)copyTo:(OTSponsorToApplicantRound2M2 *)other
154 other.voucher = _voucher;
156 if (_voucherSignature)
158 other.voucherSignature = _voucherSignature;
160 if ([self preapprovedKeysCount])
162 [other clearPreapprovedKeys];
163 NSUInteger preapprovedKeysCnt = [self preapprovedKeysCount];
164 for (NSUInteger i = 0; i < preapprovedKeysCnt; i++)
166 [other addPreapprovedKeys:[self preapprovedKeysAtIndex:i]];
171 - (id)copyWithZone:(NSZone *)zone
173 OTSponsorToApplicantRound2M2 *copy = [[[self class] allocWithZone:zone] init];
174 copy->_voucher = [_voucher copyWithZone:zone];
175 copy->_voucherSignature = [_voucherSignature copyWithZone:zone];
176 for (NSData *v in _preapprovedKeys)
178 NSData *vCopy = [v copyWithZone:zone];
179 [copy addPreapprovedKeys:vCopy];
184 - (BOOL)isEqual:(id)object
186 OTSponsorToApplicantRound2M2 *other = (OTSponsorToApplicantRound2M2 *)object;
187 return [other isMemberOfClass:[self class]]
189 ((!self->_voucher && !other->_voucher) || [self->_voucher isEqual:other->_voucher])
191 ((!self->_voucherSignature && !other->_voucherSignature) || [self->_voucherSignature isEqual:other->_voucherSignature])
193 ((!self->_preapprovedKeys && !other->_preapprovedKeys) || [self->_preapprovedKeys isEqual:other->_preapprovedKeys])
201 [self->_voucher hash]
203 [self->_voucherSignature hash]
205 [self->_preapprovedKeys hash]
209 - (void)mergeFrom:(OTSponsorToApplicantRound2M2 *)other
213 [self setVoucher:other->_voucher];
215 if (other->_voucherSignature)
217 [self setVoucherSignature:other->_voucherSignature];
219 for (NSData *iter_preapprovedKeys in other->_preapprovedKeys)
221 [self addPreapprovedKeys:iter_preapprovedKeys];