1 // This file was automatically generated by protocompiler
3 // Compiled from OTRecovery.proto
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 Recovery
18 return _peerID != nil;
20 @synthesize peerID = _peerID;
21 - (BOOL)hasSigningSPKI
23 return _signingSPKI != nil;
25 @synthesize signingSPKI = _signingSPKI;
26 - (BOOL)hasEncryptionSPKI
28 return _encryptionSPKI != nil;
30 @synthesize encryptionSPKI = _encryptionSPKI;
32 - (NSString *)description
34 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
37 - (NSDictionary *)dictionaryRepresentation
39 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
42 [dict setObject:self->_peerID forKey:@"peerID"];
44 if (self->_signingSPKI)
46 [dict setObject:self->_signingSPKI forKey:@"signingSPKI"];
48 if (self->_encryptionSPKI)
50 [dict setObject:self->_encryptionSPKI forKey:@"encryptionSPKI"];
55 BOOL RecoveryReadFrom(__unsafe_unretained Recovery *self, __unsafe_unretained PBDataReader *reader) {
56 while (PBReaderHasMoreData(reader)) {
60 PBReaderReadTag32AndType(reader, &tag, &aType);
62 if (PBReaderHasError(reader))
65 if (aType == TYPE_END_GROUP) {
73 NSString *new_peerID = PBReaderReadString(reader);
74 self->_peerID = new_peerID;
77 case 2 /* signingSPKI */:
79 NSData *new_signingSPKI = PBReaderReadData(reader);
80 self->_signingSPKI = new_signingSPKI;
83 case 3 /* encryptionSPKI */:
85 NSData *new_encryptionSPKI = PBReaderReadData(reader);
86 self->_encryptionSPKI = new_encryptionSPKI;
90 if (!PBReaderSkipValueWithTag(reader, tag, aType))
95 return !PBReaderHasError(reader);
98 - (BOOL)readFrom:(PBDataReader *)reader
100 return RecoveryReadFrom(self, reader);
102 - (void)writeTo:(PBDataWriter *)writer
108 PBDataWriterWriteStringField(writer, self->_peerID, 1);
113 if (self->_signingSPKI)
115 PBDataWriterWriteDataField(writer, self->_signingSPKI, 2);
120 if (self->_encryptionSPKI)
122 PBDataWriterWriteDataField(writer, self->_encryptionSPKI, 3);
127 - (void)copyTo:(Recovery *)other
131 other.peerID = _peerID;
135 other.signingSPKI = _signingSPKI;
139 other.encryptionSPKI = _encryptionSPKI;
143 - (id)copyWithZone:(NSZone *)zone
145 Recovery *copy = [[[self class] allocWithZone:zone] init];
146 copy->_peerID = [_peerID copyWithZone:zone];
147 copy->_signingSPKI = [_signingSPKI copyWithZone:zone];
148 copy->_encryptionSPKI = [_encryptionSPKI copyWithZone:zone];
152 - (BOOL)isEqual:(id)object
154 Recovery *other = (Recovery *)object;
155 return [other isMemberOfClass:[self class]]
157 ((!self->_peerID && !other->_peerID) || [self->_peerID isEqual:other->_peerID])
159 ((!self->_signingSPKI && !other->_signingSPKI) || [self->_signingSPKI isEqual:other->_signingSPKI])
161 ((!self->_encryptionSPKI && !other->_encryptionSPKI) || [self->_encryptionSPKI isEqual:other->_encryptionSPKI])
171 [self->_signingSPKI hash]
173 [self->_encryptionSPKI hash]
177 - (void)mergeFrom:(Recovery *)other
181 [self setPeerID:other->_peerID];
183 if (other->_signingSPKI)
185 [self setSigningSPKI:other->_signingSPKI];
187 if (other->_encryptionSPKI)
189 [self setEncryptionSPKI:other->_encryptionSPKI];