1 // This file was automatically generated by protocompiler
3 // Compiled from OTBottleContents.proto
5 #import "OTBottleContents.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
10 #import "OTPrivateKey.h"
12 #if !__has_feature(objc_arc)
13 # 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.
16 @implementation OTBottleContents
20 return _reserved1 != nil;
22 @synthesize reserved1 = _reserved1;
25 return _reserved2 != nil;
27 @synthesize reserved2 = _reserved2;
28 - (BOOL)hasPeerSigningPrivKey
30 return _peerSigningPrivKey != nil;
32 @synthesize peerSigningPrivKey = _peerSigningPrivKey;
33 - (BOOL)hasPeerEncryptionPrivKey
35 return _peerEncryptionPrivKey != nil;
37 @synthesize peerEncryptionPrivKey = _peerEncryptionPrivKey;
39 - (NSString *)description
41 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
44 - (NSDictionary *)dictionaryRepresentation
46 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
49 [dict setObject:self->_reserved1 forKey:@"reserved1"];
53 [dict setObject:self->_reserved2 forKey:@"reserved2"];
55 if (self->_peerSigningPrivKey)
57 [dict setObject:[_peerSigningPrivKey dictionaryRepresentation] forKey:@"peerSigningPrivKey"];
59 if (self->_peerEncryptionPrivKey)
61 [dict setObject:[_peerEncryptionPrivKey dictionaryRepresentation] forKey:@"peerEncryptionPrivKey"];
66 BOOL OTBottleContentsReadFrom(__unsafe_unretained OTBottleContents *self, __unsafe_unretained PBDataReader *reader) {
67 while (PBReaderHasMoreData(reader)) {
71 PBReaderReadTag32AndType(reader, &tag, &aType);
73 if (PBReaderHasError(reader))
76 if (aType == TYPE_END_GROUP) {
82 case 1 /* reserved1 */:
84 NSData *new_reserved1 = PBReaderReadData(reader);
85 self->_reserved1 = new_reserved1;
88 case 2 /* reserved2 */:
90 NSData *new_reserved2 = PBReaderReadData(reader);
91 self->_reserved2 = new_reserved2;
94 case 3 /* peerSigningPrivKey */:
96 OTPrivateKey *new_peerSigningPrivKey = [[OTPrivateKey alloc] init];
97 self->_peerSigningPrivKey = new_peerSigningPrivKey;
98 PBDataReaderMark mark_peerSigningPrivKey;
99 BOOL markError = !PBReaderPlaceMark(reader, &mark_peerSigningPrivKey);
104 BOOL inError = !OTPrivateKeyReadFrom(new_peerSigningPrivKey, reader);
109 PBReaderRecallMark(reader, &mark_peerSigningPrivKey);
112 case 4 /* peerEncryptionPrivKey */:
114 OTPrivateKey *new_peerEncryptionPrivKey = [[OTPrivateKey alloc] init];
115 self->_peerEncryptionPrivKey = new_peerEncryptionPrivKey;
116 PBDataReaderMark mark_peerEncryptionPrivKey;
117 BOOL markError = !PBReaderPlaceMark(reader, &mark_peerEncryptionPrivKey);
122 BOOL inError = !OTPrivateKeyReadFrom(new_peerEncryptionPrivKey, reader);
127 PBReaderRecallMark(reader, &mark_peerEncryptionPrivKey);
131 if (!PBReaderSkipValueWithTag(reader, tag, aType))
136 return !PBReaderHasError(reader);
139 - (BOOL)readFrom:(PBDataReader *)reader
141 return OTBottleContentsReadFrom(self, reader);
143 - (void)writeTo:(PBDataWriter *)writer
147 if (self->_reserved1)
149 PBDataWriterWriteDataField(writer, self->_reserved1, 1);
154 if (self->_reserved2)
156 PBDataWriterWriteDataField(writer, self->_reserved2, 2);
159 /* peerSigningPrivKey */
161 if (self->_peerSigningPrivKey != nil)
163 PBDataWriterWriteSubmessage(writer, self->_peerSigningPrivKey, 3);
166 /* peerEncryptionPrivKey */
168 if (self->_peerEncryptionPrivKey != nil)
170 PBDataWriterWriteSubmessage(writer, self->_peerEncryptionPrivKey, 4);
175 - (void)copyTo:(OTBottleContents *)other
179 other.reserved1 = _reserved1;
183 other.reserved2 = _reserved2;
185 if (_peerSigningPrivKey)
187 other.peerSigningPrivKey = _peerSigningPrivKey;
189 if (_peerEncryptionPrivKey)
191 other.peerEncryptionPrivKey = _peerEncryptionPrivKey;
195 - (id)copyWithZone:(NSZone *)zone
197 OTBottleContents *copy = [[[self class] allocWithZone:zone] init];
198 copy->_reserved1 = [_reserved1 copyWithZone:zone];
199 copy->_reserved2 = [_reserved2 copyWithZone:zone];
200 copy->_peerSigningPrivKey = [_peerSigningPrivKey copyWithZone:zone];
201 copy->_peerEncryptionPrivKey = [_peerEncryptionPrivKey copyWithZone:zone];
205 - (BOOL)isEqual:(id)object
207 OTBottleContents *other = (OTBottleContents *)object;
208 return [other isMemberOfClass:[self class]]
210 ((!self->_reserved1 && !other->_reserved1) || [self->_reserved1 isEqual:other->_reserved1])
212 ((!self->_reserved2 && !other->_reserved2) || [self->_reserved2 isEqual:other->_reserved2])
214 ((!self->_peerSigningPrivKey && !other->_peerSigningPrivKey) || [self->_peerSigningPrivKey isEqual:other->_peerSigningPrivKey])
216 ((!self->_peerEncryptionPrivKey && !other->_peerEncryptionPrivKey) || [self->_peerEncryptionPrivKey isEqual:other->_peerEncryptionPrivKey])
224 [self->_reserved1 hash]
226 [self->_reserved2 hash]
228 [self->_peerSigningPrivKey hash]
230 [self->_peerEncryptionPrivKey hash]
234 - (void)mergeFrom:(OTBottleContents *)other
236 if (other->_reserved1)
238 [self setReserved1:other->_reserved1];
240 if (other->_reserved2)
242 [self setReserved2:other->_reserved2];
244 if (self->_peerSigningPrivKey && other->_peerSigningPrivKey)
246 [self->_peerSigningPrivKey mergeFrom:other->_peerSigningPrivKey];
248 else if (!self->_peerSigningPrivKey && other->_peerSigningPrivKey)
250 [self setPeerSigningPrivKey:other->_peerSigningPrivKey];
252 if (self->_peerEncryptionPrivKey && other->_peerEncryptionPrivKey)
254 [self->_peerEncryptionPrivKey mergeFrom:other->_peerEncryptionPrivKey];
256 else if (!self->_peerEncryptionPrivKey && other->_peerEncryptionPrivKey)
258 [self setPeerEncryptionPrivKey:other->_peerEncryptionPrivKey];