]> git.saurik.com Git - apple/security.git/blob - keychain/analytics/C2Metric/SECC2MPGenericEvent.m
Security-59306.11.20.tar.gz
[apple/security.git] / keychain / analytics / C2Metric / SECC2MPGenericEvent.m
1 // This file was automatically generated by protocompiler
2 // DO NOT EDIT!
3 // Compiled from C2Metric.proto
4
5 #import "SECC2MPGenericEvent.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
9
10 #import "SECC2MPGenericEventMetric.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 SECC2MPGenericEvent
17
18 @synthesize type = _type;
19 - (SECC2MPGenericEvent_Type)type
20 {
21 return _has.type ? _type : SECC2MPGenericEvent_Type_none;
22 }
23 - (void)setType:(SECC2MPGenericEvent_Type)v
24 {
25 _has.type = YES;
26 _type = v;
27 }
28 - (void)setHasType:(BOOL)f
29 {
30 _has.type = f;
31 }
32 - (BOOL)hasType
33 {
34 return _has.type;
35 }
36 - (NSString *)typeAsString:(SECC2MPGenericEvent_Type)value
37 {
38 return SECC2MPGenericEvent_TypeAsString(value);
39 }
40 - (SECC2MPGenericEvent_Type)StringAsType:(NSString *)str
41 {
42 return StringAsSECC2MPGenericEvent_Type(str);
43 }
44 - (BOOL)hasName
45 {
46 return _name != nil;
47 }
48 @synthesize name = _name;
49 @synthesize timestampStart = _timestampStart;
50 - (void)setTimestampStart:(uint64_t)v
51 {
52 _has.timestampStart = YES;
53 _timestampStart = v;
54 }
55 - (void)setHasTimestampStart:(BOOL)f
56 {
57 _has.timestampStart = f;
58 }
59 - (BOOL)hasTimestampStart
60 {
61 return _has.timestampStart;
62 }
63 @synthesize timestampEnd = _timestampEnd;
64 - (void)setTimestampEnd:(uint64_t)v
65 {
66 _has.timestampEnd = YES;
67 _timestampEnd = v;
68 }
69 - (void)setHasTimestampEnd:(BOOL)f
70 {
71 _has.timestampEnd = f;
72 }
73 - (BOOL)hasTimestampEnd
74 {
75 return _has.timestampEnd;
76 }
77 @synthesize metrics = _metrics;
78 - (void)clearMetrics
79 {
80 [_metrics removeAllObjects];
81 }
82 - (void)addMetric:(SECC2MPGenericEventMetric *)i
83 {
84 if (!_metrics)
85 {
86 _metrics = [[NSMutableArray alloc] init];
87 }
88 [_metrics addObject:i];
89 }
90 - (NSUInteger)metricsCount
91 {
92 return [_metrics count];
93 }
94 - (SECC2MPGenericEventMetric *)metricAtIndex:(NSUInteger)idx
95 {
96 return [_metrics objectAtIndex:idx];
97 }
98 + (Class)metricType
99 {
100 return [SECC2MPGenericEventMetric class];
101 }
102
103 - (NSString *)description
104 {
105 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
106 }
107
108 - (NSDictionary *)dictionaryRepresentation
109 {
110 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
111 if (self->_has.type)
112 {
113 [dict setObject:SECC2MPGenericEvent_TypeAsString(self->_type) forKey:@"type"];
114 }
115 if (self->_name)
116 {
117 [dict setObject:self->_name forKey:@"name"];
118 }
119 if (self->_has.timestampStart)
120 {
121 [dict setObject:[NSNumber numberWithUnsignedLongLong:self->_timestampStart] forKey:@"timestamp_start"];
122 }
123 if (self->_has.timestampEnd)
124 {
125 [dict setObject:[NSNumber numberWithUnsignedLongLong:self->_timestampEnd] forKey:@"timestamp_end"];
126 }
127 if ([self->_metrics count])
128 {
129 NSMutableArray *metricsDictReprs = [[NSMutableArray alloc] initWithCapacity:[self->_metrics count]];
130 for (SECC2MPGenericEventMetric *i_metric in self->_metrics)
131 {
132 [metricsDictReprs addObject:[i_metric dictionaryRepresentation]];
133 }
134 [dict setObject:metricsDictReprs forKey:@"metric"];
135 }
136 return dict;
137 }
138
139 BOOL SECC2MPGenericEventReadFrom(__unsafe_unretained SECC2MPGenericEvent *self, __unsafe_unretained PBDataReader *reader) {
140 while (PBReaderHasMoreData(reader)) {
141 uint32_t tag = 0;
142 uint8_t aType = 0;
143
144 PBReaderReadTag32AndType(reader, &tag, &aType);
145
146 if (PBReaderHasError(reader))
147 break;
148
149 if (aType == TYPE_END_GROUP) {
150 break;
151 }
152
153 switch (tag) {
154
155 case 1 /* type */:
156 {
157 self->_has.type = YES;
158 self->_type = PBReaderReadInt32(reader);
159 }
160 break;
161 case 101 /* name */:
162 {
163 NSString *new_name = PBReaderReadString(reader);
164 self->_name = new_name;
165 }
166 break;
167 case 201 /* timestampStart */:
168 {
169 self->_has.timestampStart = YES;
170 self->_timestampStart = PBReaderReadUint64(reader);
171 }
172 break;
173 case 202 /* timestampEnd */:
174 {
175 self->_has.timestampEnd = YES;
176 self->_timestampEnd = PBReaderReadUint64(reader);
177 }
178 break;
179 case 301 /* metrics */:
180 {
181 SECC2MPGenericEventMetric *new_metric = [[SECC2MPGenericEventMetric alloc] init];
182 [self addMetric:new_metric];
183 PBDataReaderMark mark_metric;
184 BOOL markError = !PBReaderPlaceMark(reader, &mark_metric);
185 if (markError)
186 {
187 return NO;
188 }
189 BOOL inError = !SECC2MPGenericEventMetricReadFrom(new_metric, reader);
190 if (inError)
191 {
192 return NO;
193 }
194 PBReaderRecallMark(reader, &mark_metric);
195 }
196 break;
197 default:
198 if (!PBReaderSkipValueWithTag(reader, tag, aType))
199 return NO;
200 break;
201 }
202 }
203 return !PBReaderHasError(reader);
204 }
205
206 - (BOOL)readFrom:(PBDataReader *)reader
207 {
208 return SECC2MPGenericEventReadFrom(self, reader);
209 }
210 - (void)writeTo:(PBDataWriter *)writer
211 {
212 /* type */
213 {
214 if (self->_has.type)
215 {
216 PBDataWriterWriteInt32Field(writer, self->_type, 1);
217 }
218 }
219 /* name */
220 {
221 if (self->_name)
222 {
223 PBDataWriterWriteStringField(writer, self->_name, 101);
224 }
225 }
226 /* timestampStart */
227 {
228 if (self->_has.timestampStart)
229 {
230 PBDataWriterWriteUint64Field(writer, self->_timestampStart, 201);
231 }
232 }
233 /* timestampEnd */
234 {
235 if (self->_has.timestampEnd)
236 {
237 PBDataWriterWriteUint64Field(writer, self->_timestampEnd, 202);
238 }
239 }
240 /* metrics */
241 {
242 for (SECC2MPGenericEventMetric *i_metric in self->_metrics)
243 {
244 PBDataWriterWriteSubmessage(writer, i_metric, 301);
245 }
246 }
247 }
248
249 - (void)copyTo:(SECC2MPGenericEvent *)other
250 {
251 if (self->_has.type)
252 {
253 other->_type = _type;
254 other->_has.type = YES;
255 }
256 if (_name)
257 {
258 other.name = _name;
259 }
260 if (self->_has.timestampStart)
261 {
262 other->_timestampStart = _timestampStart;
263 other->_has.timestampStart = YES;
264 }
265 if (self->_has.timestampEnd)
266 {
267 other->_timestampEnd = _timestampEnd;
268 other->_has.timestampEnd = YES;
269 }
270 if ([self metricsCount])
271 {
272 [other clearMetrics];
273 NSUInteger metricsCnt = [self metricsCount];
274 for (NSUInteger i = 0; i < metricsCnt; i++)
275 {
276 [other addMetric:[self metricAtIndex:i]];
277 }
278 }
279 }
280
281 - (id)copyWithZone:(NSZone *)zone
282 {
283 SECC2MPGenericEvent *copy = [[[self class] allocWithZone:zone] init];
284 if (self->_has.type)
285 {
286 copy->_type = _type;
287 copy->_has.type = YES;
288 }
289 copy->_name = [_name copyWithZone:zone];
290 if (self->_has.timestampStart)
291 {
292 copy->_timestampStart = _timestampStart;
293 copy->_has.timestampStart = YES;
294 }
295 if (self->_has.timestampEnd)
296 {
297 copy->_timestampEnd = _timestampEnd;
298 copy->_has.timestampEnd = YES;
299 }
300 for (SECC2MPGenericEventMetric *v in _metrics)
301 {
302 SECC2MPGenericEventMetric *vCopy = [v copyWithZone:zone];
303 [copy addMetric:vCopy];
304 }
305 return copy;
306 }
307
308 - (BOOL)isEqual:(id)object
309 {
310 SECC2MPGenericEvent *other = (SECC2MPGenericEvent *)object;
311 return [other isMemberOfClass:[self class]]
312 &&
313 ((self->_has.type && other->_has.type && self->_type == other->_type) || (!self->_has.type && !other->_has.type))
314 &&
315 ((!self->_name && !other->_name) || [self->_name isEqual:other->_name])
316 &&
317 ((self->_has.timestampStart && other->_has.timestampStart && self->_timestampStart == other->_timestampStart) || (!self->_has.timestampStart && !other->_has.timestampStart))
318 &&
319 ((self->_has.timestampEnd && other->_has.timestampEnd && self->_timestampEnd == other->_timestampEnd) || (!self->_has.timestampEnd && !other->_has.timestampEnd))
320 &&
321 ((!self->_metrics && !other->_metrics) || [self->_metrics isEqual:other->_metrics])
322 ;
323 }
324
325 - (NSUInteger)hash
326 {
327 return 0
328 ^
329 (self->_has.type ? PBHashInt((NSUInteger)self->_type) : 0)
330 ^
331 [self->_name hash]
332 ^
333 (self->_has.timestampStart ? PBHashInt((NSUInteger)self->_timestampStart) : 0)
334 ^
335 (self->_has.timestampEnd ? PBHashInt((NSUInteger)self->_timestampEnd) : 0)
336 ^
337 [self->_metrics hash]
338 ;
339 }
340
341 - (void)mergeFrom:(SECC2MPGenericEvent *)other
342 {
343 if (other->_has.type)
344 {
345 self->_type = other->_type;
346 self->_has.type = YES;
347 }
348 if (other->_name)
349 {
350 [self setName:other->_name];
351 }
352 if (other->_has.timestampStart)
353 {
354 self->_timestampStart = other->_timestampStart;
355 self->_has.timestampStart = YES;
356 }
357 if (other->_has.timestampEnd)
358 {
359 self->_timestampEnd = other->_timestampEnd;
360 self->_has.timestampEnd = YES;
361 }
362 for (SECC2MPGenericEventMetric *iter_metrics in other->_metrics)
363 {
364 [self addMetric:iter_metrics];
365 }
366 }
367
368 @end
369