1 // This file was automatically generated by protocompiler
3 // Compiled from OTPrivateKey.proto
5 #import "OTPrivateKey.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 OTPrivateKey
16 @synthesize keyType = _keyType;
17 - (NSString *)keyTypeAsString:(OTPrivateKey_KeyType)value
19 return OTPrivateKey_KeyTypeAsString(value);
21 - (OTPrivateKey_KeyType)StringAsKeyType:(NSString *)str
23 return StringAsOTPrivateKey_KeyType(str);
25 @synthesize keyData = _keyData;
27 - (NSString *)description
29 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
32 - (NSDictionary *)dictionaryRepresentation
34 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
35 [dict setObject:OTPrivateKey_KeyTypeAsString(self->_keyType) forKey:@"keyType"];
38 [dict setObject:self->_keyData forKey:@"keyData"];
43 BOOL OTPrivateKeyReadFrom(__unsafe_unretained OTPrivateKey *self, __unsafe_unretained PBDataReader *reader) {
44 while (PBReaderHasMoreData(reader)) {
48 PBReaderReadTag32AndType(reader, &tag, &aType);
50 if (PBReaderHasError(reader))
53 if (aType == TYPE_END_GROUP) {
61 self->_keyType = PBReaderReadInt32(reader);
66 NSData *new_keyData = PBReaderReadData(reader);
67 self->_keyData = new_keyData;
71 if (!PBReaderSkipValueWithTag(reader, tag, aType))
76 return !PBReaderHasError(reader);
79 - (BOOL)readFrom:(PBDataReader *)reader
81 return OTPrivateKeyReadFrom(self, reader);
83 - (void)writeTo:(PBDataWriter *)writer
87 PBDataWriterWriteInt32Field(writer, self->_keyType, 1);
91 assert(nil != self->_keyData);
92 PBDataWriterWriteDataField(writer, self->_keyData, 2);
96 - (void)copyTo:(OTPrivateKey *)other
98 other->_keyType = _keyType;
99 other.keyData = _keyData;
102 - (id)copyWithZone:(NSZone *)zone
104 OTPrivateKey *copy = [[[self class] allocWithZone:zone] init];
105 copy->_keyType = _keyType;
106 copy->_keyData = [_keyData copyWithZone:zone];
110 - (BOOL)isEqual:(id)object
112 OTPrivateKey *other = (OTPrivateKey *)object;
113 return [other isMemberOfClass:[self class]]
115 self->_keyType == other->_keyType
117 ((!self->_keyData && !other->_keyData) || [self->_keyData isEqual:other->_keyData])
125 PBHashInt((NSUInteger)_keyType)
127 [self->_keyData hash]
131 - (void)mergeFrom:(OTPrivateKey *)other
133 self->_keyType = other->_keyType;
136 [self setKeyData:other->_keyData];