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