1 // This file was automatically generated by protocompiler
3 // Compiled from C2Metric.proto
5 #import "SECC2MPGenericEvent.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
10 #import "SECC2MPGenericEventMetric.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 SECC2MPGenericEvent
18 @synthesize type = _type;
19 - (SECC2MPGenericEvent_Type)type
21 return _has.type ? _type : SECC2MPGenericEvent_Type_none;
23 - (void)setType:(SECC2MPGenericEvent_Type)v
28 - (void)setHasType:(BOOL)f
36 - (NSString *)typeAsString:(SECC2MPGenericEvent_Type)value
38 return SECC2MPGenericEvent_TypeAsString(value);
40 - (SECC2MPGenericEvent_Type)StringAsType:(NSString *)str
42 return StringAsSECC2MPGenericEvent_Type(str);
48 @synthesize name = _name;
49 @synthesize timestampStart = _timestampStart;
50 - (void)setTimestampStart:(uint64_t)v
52 _has.timestampStart = YES;
55 - (void)setHasTimestampStart:(BOOL)f
57 _has.timestampStart = f;
59 - (BOOL)hasTimestampStart
61 return _has.timestampStart;
63 @synthesize timestampEnd = _timestampEnd;
64 - (void)setTimestampEnd:(uint64_t)v
66 _has.timestampEnd = YES;
69 - (void)setHasTimestampEnd:(BOOL)f
71 _has.timestampEnd = f;
73 - (BOOL)hasTimestampEnd
75 return _has.timestampEnd;
77 @synthesize metrics = _metrics;
80 [_metrics removeAllObjects];
82 - (void)addMetric:(SECC2MPGenericEventMetric *)i
86 _metrics = [[NSMutableArray alloc] init];
88 [_metrics addObject:i];
90 - (NSUInteger)metricsCount
92 return [_metrics count];
94 - (SECC2MPGenericEventMetric *)metricAtIndex:(NSUInteger)idx
96 return [_metrics objectAtIndex:idx];
100 return [SECC2MPGenericEventMetric class];
103 - (NSString *)description
105 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
108 - (NSDictionary *)dictionaryRepresentation
110 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
113 [dict setObject:SECC2MPGenericEvent_TypeAsString(self->_type) forKey:@"type"];
117 [dict setObject:self->_name forKey:@"name"];
119 if (self->_has.timestampStart)
121 [dict setObject:[NSNumber numberWithUnsignedLongLong:self->_timestampStart] forKey:@"timestamp_start"];
123 if (self->_has.timestampEnd)
125 [dict setObject:[NSNumber numberWithUnsignedLongLong:self->_timestampEnd] forKey:@"timestamp_end"];
127 if ([self->_metrics count])
129 NSMutableArray *metricsDictReprs = [[NSMutableArray alloc] initWithCapacity:[self->_metrics count]];
130 for (SECC2MPGenericEventMetric *i_metric in self->_metrics)
132 [metricsDictReprs addObject:[i_metric dictionaryRepresentation]];
134 [dict setObject:metricsDictReprs forKey:@"metric"];
139 BOOL SECC2MPGenericEventReadFrom(__unsafe_unretained SECC2MPGenericEvent *self, __unsafe_unretained PBDataReader *reader) {
140 while (PBReaderHasMoreData(reader)) {
144 PBReaderReadTag32AndType(reader, &tag, &aType);
146 if (PBReaderHasError(reader))
149 if (aType == TYPE_END_GROUP) {
157 self->_has.type = YES;
158 self->_type = PBReaderReadInt32(reader);
163 NSString *new_name = PBReaderReadString(reader);
164 self->_name = new_name;
167 case 201 /* timestampStart */:
169 self->_has.timestampStart = YES;
170 self->_timestampStart = PBReaderReadUint64(reader);
173 case 202 /* timestampEnd */:
175 self->_has.timestampEnd = YES;
176 self->_timestampEnd = PBReaderReadUint64(reader);
179 case 301 /* metrics */:
181 SECC2MPGenericEventMetric *new_metric = [[SECC2MPGenericEventMetric alloc] init];
182 [self addMetric:new_metric];
183 PBDataReaderMark mark_metric;
184 BOOL markError = !PBReaderPlaceMark(reader, &mark_metric);
189 BOOL inError = !SECC2MPGenericEventMetricReadFrom(new_metric, reader);
194 PBReaderRecallMark(reader, &mark_metric);
198 if (!PBReaderSkipValueWithTag(reader, tag, aType))
203 return !PBReaderHasError(reader);
206 - (BOOL)readFrom:(PBDataReader *)reader
208 return SECC2MPGenericEventReadFrom(self, reader);
210 - (void)writeTo:(PBDataWriter *)writer
216 PBDataWriterWriteInt32Field(writer, self->_type, 1);
223 PBDataWriterWriteStringField(writer, self->_name, 101);
228 if (self->_has.timestampStart)
230 PBDataWriterWriteUint64Field(writer, self->_timestampStart, 201);
235 if (self->_has.timestampEnd)
237 PBDataWriterWriteUint64Field(writer, self->_timestampEnd, 202);
242 for (SECC2MPGenericEventMetric *i_metric in self->_metrics)
244 PBDataWriterWriteSubmessage(writer, i_metric, 301);
249 - (void)copyTo:(SECC2MPGenericEvent *)other
253 other->_type = _type;
254 other->_has.type = YES;
260 if (self->_has.timestampStart)
262 other->_timestampStart = _timestampStart;
263 other->_has.timestampStart = YES;
265 if (self->_has.timestampEnd)
267 other->_timestampEnd = _timestampEnd;
268 other->_has.timestampEnd = YES;
270 if ([self metricsCount])
272 [other clearMetrics];
273 NSUInteger metricsCnt = [self metricsCount];
274 for (NSUInteger i = 0; i < metricsCnt; i++)
276 [other addMetric:[self metricAtIndex:i]];
281 - (id)copyWithZone:(NSZone *)zone
283 SECC2MPGenericEvent *copy = [[[self class] allocWithZone:zone] init];
287 copy->_has.type = YES;
289 copy->_name = [_name copyWithZone:zone];
290 if (self->_has.timestampStart)
292 copy->_timestampStart = _timestampStart;
293 copy->_has.timestampStart = YES;
295 if (self->_has.timestampEnd)
297 copy->_timestampEnd = _timestampEnd;
298 copy->_has.timestampEnd = YES;
300 for (SECC2MPGenericEventMetric *v in _metrics)
302 SECC2MPGenericEventMetric *vCopy = [v copyWithZone:zone];
303 [copy addMetric:vCopy];
308 - (BOOL)isEqual:(id)object
310 SECC2MPGenericEvent *other = (SECC2MPGenericEvent *)object;
311 return [other isMemberOfClass:[self class]]
313 ((self->_has.type && other->_has.type && self->_type == other->_type) || (!self->_has.type && !other->_has.type))
315 ((!self->_name && !other->_name) || [self->_name isEqual:other->_name])
317 ((self->_has.timestampStart && other->_has.timestampStart && self->_timestampStart == other->_timestampStart) || (!self->_has.timestampStart && !other->_has.timestampStart))
319 ((self->_has.timestampEnd && other->_has.timestampEnd && self->_timestampEnd == other->_timestampEnd) || (!self->_has.timestampEnd && !other->_has.timestampEnd))
321 ((!self->_metrics && !other->_metrics) || [self->_metrics isEqual:other->_metrics])
329 (self->_has.type ? PBHashInt((NSUInteger)self->_type) : 0)
333 (self->_has.timestampStart ? PBHashInt((NSUInteger)self->_timestampStart) : 0)
335 (self->_has.timestampEnd ? PBHashInt((NSUInteger)self->_timestampEnd) : 0)
337 [self->_metrics hash]
341 - (void)mergeFrom:(SECC2MPGenericEvent *)other
343 if (other->_has.type)
345 self->_type = other->_type;
346 self->_has.type = YES;
350 [self setName:other->_name];
352 if (other->_has.timestampStart)
354 self->_timestampStart = other->_timestampStart;
355 self->_has.timestampStart = YES;
357 if (other->_has.timestampEnd)
359 self->_timestampEnd = other->_timestampEnd;
360 self->_has.timestampEnd = YES;
362 for (SECC2MPGenericEventMetric *iter_metrics in other->_metrics)
364 [self addMetric:iter_metrics];