1 // This file was automatically generated by protocompiler
3 // Compiled from C2Metric.proto
5 #import "SECC2MPGenericEventMetricValue.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 SECC2MPGenericEventMetricValue
18 - (BOOL)hasStringValue
20 return _stringValue != nil;
22 @synthesize stringValue = _stringValue;
23 @synthesize doubleValue = _doubleValue;
24 - (void)setDoubleValue:(double)v
26 _has.doubleValue = YES;
29 - (void)setHasDoubleValue:(BOOL)f
33 - (BOOL)hasDoubleValue
35 return _has.doubleValue;
37 @synthesize dateValue = _dateValue;
38 - (void)setDateValue:(uint64_t)v
43 - (void)setHasDateValue:(BOOL)f
49 return _has.dateValue;
53 return _errorValue != nil;
55 @synthesize errorValue = _errorValue;
57 - (NSString *)description
59 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
62 - (NSDictionary *)dictionaryRepresentation
64 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
65 if (self->_stringValue)
67 [dict setObject:self->_stringValue forKey:@"string_value"];
69 if (self->_has.doubleValue)
71 [dict setObject:[NSNumber numberWithDouble:self->_doubleValue] forKey:@"double_value"];
73 if (self->_has.dateValue)
75 [dict setObject:[NSNumber numberWithUnsignedLongLong:self->_dateValue] forKey:@"date_value"];
77 if (self->_errorValue)
79 [dict setObject:[_errorValue dictionaryRepresentation] forKey:@"error_value"];
84 BOOL SECC2MPGenericEventMetricValueReadFrom(__unsafe_unretained SECC2MPGenericEventMetricValue *self, __unsafe_unretained PBDataReader *reader) {
85 while (PBReaderHasMoreData(reader)) {
89 PBReaderReadTag32AndType(reader, &tag, &aType);
91 if (PBReaderHasError(reader))
94 if (aType == TYPE_END_GROUP) {
100 case 101 /* stringValue */:
102 NSString *new_stringValue = PBReaderReadString(reader);
103 self->_stringValue = new_stringValue;
106 case 102 /* doubleValue */:
108 self->_has.doubleValue = YES;
109 self->_doubleValue = PBReaderReadDouble(reader);
112 case 103 /* dateValue */:
114 self->_has.dateValue = YES;
115 self->_dateValue = PBReaderReadUint64(reader);
118 case 201 /* errorValue */:
120 SECC2MPError *new_errorValue = [[SECC2MPError alloc] init];
121 self->_errorValue = new_errorValue;
122 PBDataReaderMark mark_errorValue;
123 BOOL markError = !PBReaderPlaceMark(reader, &mark_errorValue);
128 BOOL inError = !SECC2MPErrorReadFrom(new_errorValue, reader);
133 PBReaderRecallMark(reader, &mark_errorValue);
137 if (!PBReaderSkipValueWithTag(reader, tag, aType))
142 return !PBReaderHasError(reader);
145 - (BOOL)readFrom:(PBDataReader *)reader
147 return SECC2MPGenericEventMetricValueReadFrom(self, reader);
149 - (void)writeTo:(PBDataWriter *)writer
153 if (self->_stringValue)
155 PBDataWriterWriteStringField(writer, self->_stringValue, 101);
160 if (self->_has.doubleValue)
162 PBDataWriterWriteDoubleField(writer, self->_doubleValue, 102);
167 if (self->_has.dateValue)
169 PBDataWriterWriteUint64Field(writer, self->_dateValue, 103);
174 if (self->_errorValue != nil)
176 PBDataWriterWriteSubmessage(writer, self->_errorValue, 201);
181 - (void)copyTo:(SECC2MPGenericEventMetricValue *)other
185 other.stringValue = _stringValue;
187 if (self->_has.doubleValue)
189 other->_doubleValue = _doubleValue;
190 other->_has.doubleValue = YES;
192 if (self->_has.dateValue)
194 other->_dateValue = _dateValue;
195 other->_has.dateValue = YES;
199 other.errorValue = _errorValue;
203 - (id)copyWithZone:(NSZone *)zone
205 SECC2MPGenericEventMetricValue *copy = [[[self class] allocWithZone:zone] init];
206 copy->_stringValue = [_stringValue copyWithZone:zone];
207 if (self->_has.doubleValue)
209 copy->_doubleValue = _doubleValue;
210 copy->_has.doubleValue = YES;
212 if (self->_has.dateValue)
214 copy->_dateValue = _dateValue;
215 copy->_has.dateValue = YES;
217 copy->_errorValue = [_errorValue copyWithZone:zone];
221 - (BOOL)isEqual:(id)object
223 SECC2MPGenericEventMetricValue *other = (SECC2MPGenericEventMetricValue *)object;
224 return [other isMemberOfClass:[self class]]
226 ((!self->_stringValue && !other->_stringValue) || [self->_stringValue isEqual:other->_stringValue])
228 ((self->_has.doubleValue && other->_has.doubleValue && self->_doubleValue == other->_doubleValue) || (!self->_has.doubleValue && !other->_has.doubleValue))
230 ((self->_has.dateValue && other->_has.dateValue && self->_dateValue == other->_dateValue) || (!self->_has.dateValue && !other->_has.dateValue))
232 ((!self->_errorValue && !other->_errorValue) || [self->_errorValue isEqual:other->_errorValue])
240 [self->_stringValue hash]
242 (self->_has.doubleValue ? PBHashDouble(self->_doubleValue) : 0)
244 (self->_has.dateValue ? PBHashInt((NSUInteger)self->_dateValue) : 0)
246 [self->_errorValue hash]
250 - (void)mergeFrom:(SECC2MPGenericEventMetricValue *)other
252 if (other->_stringValue)
254 [self setStringValue:other->_stringValue];
256 if (other->_has.doubleValue)
258 self->_doubleValue = other->_doubleValue;
259 self->_has.doubleValue = YES;
261 if (other->_has.dateValue)
263 self->_dateValue = other->_dateValue;
264 self->_has.dateValue = YES;
266 if (self->_errorValue && other->_errorValue)
268 [self->_errorValue mergeFrom:other->_errorValue];
270 else if (!self->_errorValue && other->_errorValue)
272 [self setErrorValue:other->_errorValue];