OTBottleContents.m   [plain text]

// This file was automatically generated by protocompiler
// DO NOT EDIT!
// Compiled from OTBottleContents.proto

#import "OTBottleContents.h"
#import <ProtocolBuffer/PBConstants.h>
#import <ProtocolBuffer/PBHashUtil.h>
#import <ProtocolBuffer/PBDataReader.h>

#import "OTPrivateKey.h"

#if !__has_feature(objc_arc)
# 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.
#endif

@implementation OTBottleContents

- (BOOL)hasReserved1
{
return _reserved1 != nil;
}
@synthesize reserved1 = _reserved1;
- (BOOL)hasReserved2
{
return _reserved2 != nil;
}
@synthesize reserved2 = _reserved2;
- (BOOL)hasPeerSigningPrivKey
{
return _peerSigningPrivKey != nil;
}
@synthesize peerSigningPrivKey = _peerSigningPrivKey;
- (BOOL)hasPeerEncryptionPrivKey
{
return _peerEncryptionPrivKey != nil;
}
@synthesize peerEncryptionPrivKey = _peerEncryptionPrivKey;

- (NSString *)description
{
return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
}

- (NSDictionary *)dictionaryRepresentation
{
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
if (self->_reserved1)
{
[dict setObject:self->_reserved1 forKey:@"reserved1"];
}
if (self->_reserved2)
{
[dict setObject:self->_reserved2 forKey:@"reserved2"];
}
if (self->_peerSigningPrivKey)
{
[dict setObject:[_peerSigningPrivKey dictionaryRepresentation] forKey:@"peerSigningPrivKey"];
}
if (self->_peerEncryptionPrivKey)
{
[dict setObject:[_peerEncryptionPrivKey dictionaryRepresentation] forKey:@"peerEncryptionPrivKey"];
}
return dict;
}

BOOL OTBottleContentsReadFrom(__unsafe_unretained OTBottleContents *self, __unsafe_unretained PBDataReader *reader) {
while (PBReaderHasMoreData(reader)) {
uint32_t tag = 0;
uint8_t aType = 0;

PBReaderReadTag32AndType(reader, &tag, &aType);

if (PBReaderHasError(reader))
break;

if (aType == TYPE_END_GROUP) {
break;
}

switch (tag) {

case 1 /* reserved1 */:
{
NSData *new_reserved1 = PBReaderReadData(reader);
self->_reserved1 = new_reserved1;
}
break;
case 2 /* reserved2 */:
{
NSData *new_reserved2 = PBReaderReadData(reader);
self->_reserved2 = new_reserved2;
}
break;
case 3 /* peerSigningPrivKey */:
{
OTPrivateKey *new_peerSigningPrivKey = [[OTPrivateKey alloc] init];
self->_peerSigningPrivKey = new_peerSigningPrivKey;
PBDataReaderMark mark_peerSigningPrivKey;
BOOL markError = !PBReaderPlaceMark(reader, &mark_peerSigningPrivKey);
if (markError)
{
return NO;
}
BOOL inError = !OTPrivateKeyReadFrom(new_peerSigningPrivKey, reader);
if (inError)
{
return NO;
}
PBReaderRecallMark(reader, &mark_peerSigningPrivKey);
}
break;
case 4 /* peerEncryptionPrivKey */:
{
OTPrivateKey *new_peerEncryptionPrivKey = [[OTPrivateKey alloc] init];
self->_peerEncryptionPrivKey = new_peerEncryptionPrivKey;
PBDataReaderMark mark_peerEncryptionPrivKey;
BOOL markError = !PBReaderPlaceMark(reader, &mark_peerEncryptionPrivKey);
if (markError)
{
return NO;
}
BOOL inError = !OTPrivateKeyReadFrom(new_peerEncryptionPrivKey, reader);
if (inError)
{
return NO;
}
PBReaderRecallMark(reader, &mark_peerEncryptionPrivKey);
}
break;
default:
if (!PBReaderSkipValueWithTag(reader, tag, aType))
return NO;
break;
}
}
return !PBReaderHasError(reader);
}

- (BOOL)readFrom:(PBDataReader *)reader
{
return OTBottleContentsReadFrom(self, reader);
}
- (void)writeTo:(PBDataWriter *)writer
{
/* reserved1 */
{
if (self->_reserved1)
{
PBDataWriterWriteDataField(writer, self->_reserved1, 1);
}
}
/* reserved2 */
{
if (self->_reserved2)
{
PBDataWriterWriteDataField(writer, self->_reserved2, 2);
}
}
/* peerSigningPrivKey */
{
if (self->_peerSigningPrivKey != nil)
{
PBDataWriterWriteSubmessage(writer, self->_peerSigningPrivKey, 3);
}
}
/* peerEncryptionPrivKey */
{
if (self->_peerEncryptionPrivKey != nil)
{
PBDataWriterWriteSubmessage(writer, self->_peerEncryptionPrivKey, 4);
}
}
}

- (void)copyTo:(OTBottleContents *)other
{
if (_reserved1)
{
other.reserved1 = _reserved1;
}
if (_reserved2)
{
other.reserved2 = _reserved2;
}
if (_peerSigningPrivKey)
{
other.peerSigningPrivKey = _peerSigningPrivKey;
}
if (_peerEncryptionPrivKey)
{
other.peerEncryptionPrivKey = _peerEncryptionPrivKey;
}
}

- (id)copyWithZone:(NSZone *)zone
{
OTBottleContents *copy = [[[self class] allocWithZone:zone] init];
copy->_reserved1 = [_reserved1 copyWithZone:zone];
copy->_reserved2 = [_reserved2 copyWithZone:zone];
copy->_peerSigningPrivKey = [_peerSigningPrivKey copyWithZone:zone];
copy->_peerEncryptionPrivKey = [_peerEncryptionPrivKey copyWithZone:zone];
return copy;
}

- (BOOL)isEqual:(id)object
{
OTBottleContents *other = (OTBottleContents *)object;
return [other isMemberOfClass:[self class]]
&&
((!self->_reserved1 && !other->_reserved1) || [self->_reserved1 isEqual:other->_reserved1])
&&
((!self->_reserved2 && !other->_reserved2) || [self->_reserved2 isEqual:other->_reserved2])
&&
((!self->_peerSigningPrivKey && !other->_peerSigningPrivKey) || [self->_peerSigningPrivKey isEqual:other->_peerSigningPrivKey])
&&
((!self->_peerEncryptionPrivKey && !other->_peerEncryptionPrivKey) || [self->_peerEncryptionPrivKey isEqual:other->_peerEncryptionPrivKey])
;
}

- (NSUInteger)hash
{
return 0
^
[self->_reserved1 hash]
^
[self->_reserved2 hash]
^
[self->_peerSigningPrivKey hash]
^
[self->_peerEncryptionPrivKey hash]
;
}

- (void)mergeFrom:(OTBottleContents *)other
{
if (other->_reserved1)
{
[self setReserved1:other->_reserved1];
}
if (other->_reserved2)
{
[self setReserved2:other->_reserved2];
}
if (self->_peerSigningPrivKey && other->_peerSigningPrivKey)
{
[self->_peerSigningPrivKey mergeFrom:other->_peerSigningPrivKey];
}
else if (!self->_peerSigningPrivKey && other->_peerSigningPrivKey)
{
[self setPeerSigningPrivKey:other->_peerSigningPrivKey];
}
if (self->_peerEncryptionPrivKey && other->_peerEncryptionPrivKey)
{
[self->_peerEncryptionPrivKey mergeFrom:other->_peerEncryptionPrivKey];
}
else if (!self->_peerEncryptionPrivKey && other->_peerEncryptionPrivKey)
{
[self setPeerEncryptionPrivKey:other->_peerEncryptionPrivKey];
}
}

@end