1 // This file was automatically generated by protocompiler
3 // Compiled from OTPairingMessage.proto
5 #import "OTSOSMessage.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 OTSOSMessage
18 return _credential != nil;
20 @synthesize credential = _credential;
23 return _peerInfo != nil;
25 @synthesize peerInfo = _peerInfo;
28 return _circleBlob != nil;
30 @synthesize circleBlob = _circleBlob;
31 - (BOOL)hasInitialSyncItems
33 return _initialSyncItems != nil;
35 @synthesize initialSyncItems = _initialSyncItems;
37 - (NSString *)description
39 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
42 - (NSDictionary *)dictionaryRepresentation
44 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
45 if (self->_credential)
47 [dict setObject:self->_credential forKey:@"credential"];
51 [dict setObject:self->_peerInfo forKey:@"peerInfo"];
53 if (self->_circleBlob)
55 [dict setObject:self->_circleBlob forKey:@"circleBlob"];
57 if (self->_initialSyncItems)
59 [dict setObject:self->_initialSyncItems forKey:@"initialSyncItems"];
64 BOOL OTSOSMessageReadFrom(__unsafe_unretained OTSOSMessage *self, __unsafe_unretained PBDataReader *reader) {
65 while (PBReaderHasMoreData(reader)) {
69 PBReaderReadTag32AndType(reader, &tag, &aType);
71 if (PBReaderHasError(reader))
74 if (aType == TYPE_END_GROUP) {
80 case 1 /* credential */:
82 NSData *new_credential = PBReaderReadData(reader);
83 self->_credential = new_credential;
86 case 2 /* peerInfo */:
88 NSData *new_peerInfo = PBReaderReadData(reader);
89 self->_peerInfo = new_peerInfo;
92 case 3 /* circleBlob */:
94 NSData *new_circleBlob = PBReaderReadData(reader);
95 self->_circleBlob = new_circleBlob;
98 case 4 /* initialSyncItems */:
100 NSData *new_initialSyncItems = PBReaderReadData(reader);
101 self->_initialSyncItems = new_initialSyncItems;
105 if (!PBReaderSkipValueWithTag(reader, tag, aType))
110 return !PBReaderHasError(reader);
113 - (BOOL)readFrom:(PBDataReader *)reader
115 return OTSOSMessageReadFrom(self, reader);
117 - (void)writeTo:(PBDataWriter *)writer
121 if (self->_credential)
123 PBDataWriterWriteDataField(writer, self->_credential, 1);
130 PBDataWriterWriteDataField(writer, self->_peerInfo, 2);
135 if (self->_circleBlob)
137 PBDataWriterWriteDataField(writer, self->_circleBlob, 3);
140 /* initialSyncItems */
142 if (self->_initialSyncItems)
144 PBDataWriterWriteDataField(writer, self->_initialSyncItems, 4);
149 - (void)copyTo:(OTSOSMessage *)other
153 other.credential = _credential;
157 other.peerInfo = _peerInfo;
161 other.circleBlob = _circleBlob;
163 if (_initialSyncItems)
165 other.initialSyncItems = _initialSyncItems;
169 - (id)copyWithZone:(NSZone *)zone
171 OTSOSMessage *copy = [[[self class] allocWithZone:zone] init];
172 copy->_credential = [_credential copyWithZone:zone];
173 copy->_peerInfo = [_peerInfo copyWithZone:zone];
174 copy->_circleBlob = [_circleBlob copyWithZone:zone];
175 copy->_initialSyncItems = [_initialSyncItems copyWithZone:zone];
179 - (BOOL)isEqual:(id)object
181 OTSOSMessage *other = (OTSOSMessage *)object;
182 return [other isMemberOfClass:[self class]]
184 ((!self->_credential && !other->_credential) || [self->_credential isEqual:other->_credential])
186 ((!self->_peerInfo && !other->_peerInfo) || [self->_peerInfo isEqual:other->_peerInfo])
188 ((!self->_circleBlob && !other->_circleBlob) || [self->_circleBlob isEqual:other->_circleBlob])
190 ((!self->_initialSyncItems && !other->_initialSyncItems) || [self->_initialSyncItems isEqual:other->_initialSyncItems])
198 [self->_credential hash]
200 [self->_peerInfo hash]
202 [self->_circleBlob hash]
204 [self->_initialSyncItems hash]
208 - (void)mergeFrom:(OTSOSMessage *)other
210 if (other->_credential)
212 [self setCredential:other->_credential];
214 if (other->_peerInfo)
216 [self setPeerInfo:other->_peerInfo];
218 if (other->_circleBlob)
220 [self setCircleBlob:other->_circleBlob];
222 if (other->_initialSyncItems)
224 [self setInitialSyncItems:other->_initialSyncItems];