1 // This file was automatically generated by protocompiler
3 // Compiled from C2Metric.proto
5 #import "SECC2MPError.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
10 #import "SECC2MPError.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 SECC2MPError
18 - (BOOL)hasErrorDomain
20 return _errorDomain != nil;
22 @synthesize errorDomain = _errorDomain;
23 @synthesize errorCode = _errorCode;
24 - (void)setErrorCode:(int64_t)v
29 - (void)setHasErrorCode:(BOOL)f
35 return _has.errorCode;
37 - (BOOL)hasErrorDescription
39 return _errorDescription != nil;
41 @synthesize errorDescription = _errorDescription;
42 - (BOOL)hasUnderlyingError
44 return _underlyingError != nil;
46 @synthesize underlyingError = _underlyingError;
48 - (NSString *)description
50 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
53 - (NSDictionary *)dictionaryRepresentation
55 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
56 if (self->_errorDomain)
58 [dict setObject:self->_errorDomain forKey:@"error_domain"];
60 if (self->_has.errorCode)
62 [dict setObject:[NSNumber numberWithLongLong:self->_errorCode] forKey:@"error_code"];
64 if (self->_errorDescription)
66 [dict setObject:self->_errorDescription forKey:@"error_description"];
68 if (self->_underlyingError)
70 [dict setObject:[_underlyingError dictionaryRepresentation] forKey:@"underlying_error"];
75 BOOL SECC2MPErrorReadFrom(__unsafe_unretained SECC2MPError *self, __unsafe_unretained PBDataReader *reader) {
76 while (PBReaderHasMoreData(reader)) {
80 PBReaderReadTag32AndType(reader, &tag, &aType);
82 if (PBReaderHasError(reader))
85 if (aType == TYPE_END_GROUP) {
91 case 1 /* errorDomain */:
93 NSString *new_errorDomain = PBReaderReadString(reader);
94 self->_errorDomain = new_errorDomain;
97 case 2 /* errorCode */:
99 self->_has.errorCode = YES;
100 self->_errorCode = PBReaderReadInt64(reader);
103 case 3 /* errorDescription */:
105 NSString *new_errorDescription = PBReaderReadString(reader);
106 self->_errorDescription = new_errorDescription;
109 case 4 /* underlyingError */:
111 SECC2MPError *new_underlyingError = [[SECC2MPError alloc] init];
112 self->_underlyingError = new_underlyingError;
113 PBDataReaderMark mark_underlyingError;
114 BOOL markError = !PBReaderPlaceMark(reader, &mark_underlyingError);
119 BOOL inError = !SECC2MPErrorReadFrom(new_underlyingError, reader);
124 PBReaderRecallMark(reader, &mark_underlyingError);
128 if (!PBReaderSkipValueWithTag(reader, tag, aType))
133 return !PBReaderHasError(reader);
136 - (BOOL)readFrom:(PBDataReader *)reader
138 return SECC2MPErrorReadFrom(self, reader);
140 - (void)writeTo:(PBDataWriter *)writer
144 if (self->_errorDomain)
146 PBDataWriterWriteStringField(writer, self->_errorDomain, 1);
151 if (self->_has.errorCode)
153 PBDataWriterWriteInt64Field(writer, self->_errorCode, 2);
156 /* errorDescription */
158 if (self->_errorDescription)
160 PBDataWriterWriteStringField(writer, self->_errorDescription, 3);
163 /* underlyingError */
165 if (self->_underlyingError != nil)
167 PBDataWriterWriteSubmessage(writer, self->_underlyingError, 4);
172 - (void)copyTo:(SECC2MPError *)other
176 other.errorDomain = _errorDomain;
178 if (self->_has.errorCode)
180 other->_errorCode = _errorCode;
181 other->_has.errorCode = YES;
183 if (_errorDescription)
185 other.errorDescription = _errorDescription;
187 if (_underlyingError)
189 other.underlyingError = _underlyingError;
193 - (id)copyWithZone:(NSZone *)zone
195 SECC2MPError *copy = [[[self class] allocWithZone:zone] init];
196 copy->_errorDomain = [_errorDomain copyWithZone:zone];
197 if (self->_has.errorCode)
199 copy->_errorCode = _errorCode;
200 copy->_has.errorCode = YES;
202 copy->_errorDescription = [_errorDescription copyWithZone:zone];
203 copy->_underlyingError = [_underlyingError copyWithZone:zone];
207 - (BOOL)isEqual:(id)object
209 SECC2MPError *other = (SECC2MPError *)object;
210 return [other isMemberOfClass:[self class]]
212 ((!self->_errorDomain && !other->_errorDomain) || [self->_errorDomain isEqual:other->_errorDomain])
214 ((self->_has.errorCode && other->_has.errorCode && self->_errorCode == other->_errorCode) || (!self->_has.errorCode && !other->_has.errorCode))
216 ((!self->_errorDescription && !other->_errorDescription) || [self->_errorDescription isEqual:other->_errorDescription])
218 ((!self->_underlyingError && !other->_underlyingError) || [self->_underlyingError isEqual:other->_underlyingError])
226 [self->_errorDomain hash]
228 (self->_has.errorCode ? PBHashInt((NSUInteger)self->_errorCode) : 0)
230 [self->_errorDescription hash]
232 [self->_underlyingError hash]
236 - (void)mergeFrom:(SECC2MPError *)other
238 if (other->_errorDomain)
240 [self setErrorDomain:other->_errorDomain];
242 if (other->_has.errorCode)
244 self->_errorCode = other->_errorCode;
245 self->_has.errorCode = YES;
247 if (other->_errorDescription)
249 [self setErrorDescription:other->_errorDescription];
251 if (self->_underlyingError && other->_underlyingError)
253 [self->_underlyingError mergeFrom:other->_underlyingError];
255 else if (!self->_underlyingError && other->_underlyingError)
257 [self setUnderlyingError:other->_underlyingError];