]> git.saurik.com Git - apple/security.git/blob - keychain/analytics/C2Metric/SECC2MPError.m
Security-59306.11.20.tar.gz
[apple/security.git] / keychain / analytics / C2Metric / SECC2MPError.m
1 // This file was automatically generated by protocompiler
2 // DO NOT EDIT!
3 // Compiled from C2Metric.proto
4
5 #import "SECC2MPError.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
9
10 #import "SECC2MPError.h"
11
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.
14 #endif
15
16 @implementation SECC2MPError
17
18 - (BOOL)hasErrorDomain
19 {
20 return _errorDomain != nil;
21 }
22 @synthesize errorDomain = _errorDomain;
23 @synthesize errorCode = _errorCode;
24 - (void)setErrorCode:(int64_t)v
25 {
26 _has.errorCode = YES;
27 _errorCode = v;
28 }
29 - (void)setHasErrorCode:(BOOL)f
30 {
31 _has.errorCode = f;
32 }
33 - (BOOL)hasErrorCode
34 {
35 return _has.errorCode;
36 }
37 - (BOOL)hasErrorDescription
38 {
39 return _errorDescription != nil;
40 }
41 @synthesize errorDescription = _errorDescription;
42 - (BOOL)hasUnderlyingError
43 {
44 return _underlyingError != nil;
45 }
46 @synthesize underlyingError = _underlyingError;
47
48 - (NSString *)description
49 {
50 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
51 }
52
53 - (NSDictionary *)dictionaryRepresentation
54 {
55 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
56 if (self->_errorDomain)
57 {
58 [dict setObject:self->_errorDomain forKey:@"error_domain"];
59 }
60 if (self->_has.errorCode)
61 {
62 [dict setObject:[NSNumber numberWithLongLong:self->_errorCode] forKey:@"error_code"];
63 }
64 if (self->_errorDescription)
65 {
66 [dict setObject:self->_errorDescription forKey:@"error_description"];
67 }
68 if (self->_underlyingError)
69 {
70 [dict setObject:[_underlyingError dictionaryRepresentation] forKey:@"underlying_error"];
71 }
72 return dict;
73 }
74
75 BOOL SECC2MPErrorReadFrom(__unsafe_unretained SECC2MPError *self, __unsafe_unretained PBDataReader *reader) {
76 while (PBReaderHasMoreData(reader)) {
77 uint32_t tag = 0;
78 uint8_t aType = 0;
79
80 PBReaderReadTag32AndType(reader, &tag, &aType);
81
82 if (PBReaderHasError(reader))
83 break;
84
85 if (aType == TYPE_END_GROUP) {
86 break;
87 }
88
89 switch (tag) {
90
91 case 1 /* errorDomain */:
92 {
93 NSString *new_errorDomain = PBReaderReadString(reader);
94 self->_errorDomain = new_errorDomain;
95 }
96 break;
97 case 2 /* errorCode */:
98 {
99 self->_has.errorCode = YES;
100 self->_errorCode = PBReaderReadInt64(reader);
101 }
102 break;
103 case 3 /* errorDescription */:
104 {
105 NSString *new_errorDescription = PBReaderReadString(reader);
106 self->_errorDescription = new_errorDescription;
107 }
108 break;
109 case 4 /* underlyingError */:
110 {
111 SECC2MPError *new_underlyingError = [[SECC2MPError alloc] init];
112 self->_underlyingError = new_underlyingError;
113 PBDataReaderMark mark_underlyingError;
114 BOOL markError = !PBReaderPlaceMark(reader, &mark_underlyingError);
115 if (markError)
116 {
117 return NO;
118 }
119 BOOL inError = !SECC2MPErrorReadFrom(new_underlyingError, reader);
120 if (inError)
121 {
122 return NO;
123 }
124 PBReaderRecallMark(reader, &mark_underlyingError);
125 }
126 break;
127 default:
128 if (!PBReaderSkipValueWithTag(reader, tag, aType))
129 return NO;
130 break;
131 }
132 }
133 return !PBReaderHasError(reader);
134 }
135
136 - (BOOL)readFrom:(PBDataReader *)reader
137 {
138 return SECC2MPErrorReadFrom(self, reader);
139 }
140 - (void)writeTo:(PBDataWriter *)writer
141 {
142 /* errorDomain */
143 {
144 if (self->_errorDomain)
145 {
146 PBDataWriterWriteStringField(writer, self->_errorDomain, 1);
147 }
148 }
149 /* errorCode */
150 {
151 if (self->_has.errorCode)
152 {
153 PBDataWriterWriteInt64Field(writer, self->_errorCode, 2);
154 }
155 }
156 /* errorDescription */
157 {
158 if (self->_errorDescription)
159 {
160 PBDataWriterWriteStringField(writer, self->_errorDescription, 3);
161 }
162 }
163 /* underlyingError */
164 {
165 if (self->_underlyingError != nil)
166 {
167 PBDataWriterWriteSubmessage(writer, self->_underlyingError, 4);
168 }
169 }
170 }
171
172 - (void)copyTo:(SECC2MPError *)other
173 {
174 if (_errorDomain)
175 {
176 other.errorDomain = _errorDomain;
177 }
178 if (self->_has.errorCode)
179 {
180 other->_errorCode = _errorCode;
181 other->_has.errorCode = YES;
182 }
183 if (_errorDescription)
184 {
185 other.errorDescription = _errorDescription;
186 }
187 if (_underlyingError)
188 {
189 other.underlyingError = _underlyingError;
190 }
191 }
192
193 - (id)copyWithZone:(NSZone *)zone
194 {
195 SECC2MPError *copy = [[[self class] allocWithZone:zone] init];
196 copy->_errorDomain = [_errorDomain copyWithZone:zone];
197 if (self->_has.errorCode)
198 {
199 copy->_errorCode = _errorCode;
200 copy->_has.errorCode = YES;
201 }
202 copy->_errorDescription = [_errorDescription copyWithZone:zone];
203 copy->_underlyingError = [_underlyingError copyWithZone:zone];
204 return copy;
205 }
206
207 - (BOOL)isEqual:(id)object
208 {
209 SECC2MPError *other = (SECC2MPError *)object;
210 return [other isMemberOfClass:[self class]]
211 &&
212 ((!self->_errorDomain && !other->_errorDomain) || [self->_errorDomain isEqual:other->_errorDomain])
213 &&
214 ((self->_has.errorCode && other->_has.errorCode && self->_errorCode == other->_errorCode) || (!self->_has.errorCode && !other->_has.errorCode))
215 &&
216 ((!self->_errorDescription && !other->_errorDescription) || [self->_errorDescription isEqual:other->_errorDescription])
217 &&
218 ((!self->_underlyingError && !other->_underlyingError) || [self->_underlyingError isEqual:other->_underlyingError])
219 ;
220 }
221
222 - (NSUInteger)hash
223 {
224 return 0
225 ^
226 [self->_errorDomain hash]
227 ^
228 (self->_has.errorCode ? PBHashInt((NSUInteger)self->_errorCode) : 0)
229 ^
230 [self->_errorDescription hash]
231 ^
232 [self->_underlyingError hash]
233 ;
234 }
235
236 - (void)mergeFrom:(SECC2MPError *)other
237 {
238 if (other->_errorDomain)
239 {
240 [self setErrorDomain:other->_errorDomain];
241 }
242 if (other->_has.errorCode)
243 {
244 self->_errorCode = other->_errorCode;
245 self->_has.errorCode = YES;
246 }
247 if (other->_errorDescription)
248 {
249 [self setErrorDescription:other->_errorDescription];
250 }
251 if (self->_underlyingError && other->_underlyingError)
252 {
253 [self->_underlyingError mergeFrom:other->_underlyingError];
254 }
255 else if (!self->_underlyingError && other->_underlyingError)
256 {
257 [self setUnderlyingError:other->_underlyingError];
258 }
259 }
260
261 @end
262