]> git.saurik.com Git - apple/security.git/blob - keychain/analytics/C2Metric/SECC2MPGenericEventMetric.m
Security-59754.80.3.tar.gz
[apple/security.git] / keychain / analytics / C2Metric / SECC2MPGenericEventMetric.m
1 // This file was automatically generated by protocompiler
2 // DO NOT EDIT!
3 // Compiled from C2Metric.proto
4
5 #import "SECC2MPGenericEventMetric.h"
6 #import <ProtocolBuffer/PBConstants.h>
7 #import <ProtocolBuffer/PBHashUtil.h>
8 #import <ProtocolBuffer/PBDataReader.h>
9
10 #import "SECC2MPGenericEventMetricValue.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 SECC2MPGenericEventMetric
17
18 - (BOOL)hasKey
19 {
20 return _key != nil;
21 }
22 @synthesize key = _key;
23 - (BOOL)hasValue
24 {
25 return _value != nil;
26 }
27 @synthesize value = _value;
28
29 - (NSString *)description
30 {
31 return [NSString stringWithFormat:@"%@ %@", [super description], [self dictionaryRepresentation]];
32 }
33
34 - (NSDictionary *)dictionaryRepresentation
35 {
36 NSMutableDictionary *dict = [NSMutableDictionary dictionary];
37 if (self->_key)
38 {
39 [dict setObject:self->_key forKey:@"key"];
40 }
41 if (self->_value)
42 {
43 [dict setObject:[_value dictionaryRepresentation] forKey:@"value"];
44 }
45 return dict;
46 }
47
48 BOOL SECC2MPGenericEventMetricReadFrom(__unsafe_unretained SECC2MPGenericEventMetric *self, __unsafe_unretained PBDataReader *reader) {
49 while (PBReaderHasMoreData(reader)) {
50 uint32_t tag = 0;
51 uint8_t aType = 0;
52
53 PBReaderReadTag32AndType(reader, &tag, &aType);
54
55 if (PBReaderHasError(reader))
56 break;
57
58 if (aType == TYPE_END_GROUP) {
59 break;
60 }
61
62 switch (tag) {
63
64 case 101 /* key */:
65 {
66 NSString *new_key = PBReaderReadString(reader);
67 self->_key = new_key;
68 }
69 break;
70 case 201 /* value */:
71 {
72 SECC2MPGenericEventMetricValue *new_value = [[SECC2MPGenericEventMetricValue alloc] init];
73 self->_value = new_value;
74 PBDataReaderMark mark_value;
75 BOOL markError = !PBReaderPlaceMark(reader, &mark_value);
76 if (markError)
77 {
78 return NO;
79 }
80 BOOL inError = !SECC2MPGenericEventMetricValueReadFrom(new_value, reader);
81 if (inError)
82 {
83 return NO;
84 }
85 PBReaderRecallMark(reader, &mark_value);
86 }
87 break;
88 default:
89 if (!PBReaderSkipValueWithTag(reader, tag, aType))
90 return NO;
91 break;
92 }
93 }
94 return !PBReaderHasError(reader);
95 }
96
97 - (BOOL)readFrom:(PBDataReader *)reader
98 {
99 return SECC2MPGenericEventMetricReadFrom(self, reader);
100 }
101 - (void)writeTo:(PBDataWriter *)writer
102 {
103 /* key */
104 {
105 if (self->_key)
106 {
107 PBDataWriterWriteStringField(writer, self->_key, 101);
108 }
109 }
110 /* value */
111 {
112 if (self->_value != nil)
113 {
114 PBDataWriterWriteSubmessage(writer, self->_value, 201);
115 }
116 }
117 }
118
119 - (void)copyTo:(SECC2MPGenericEventMetric *)other
120 {
121 if (_key)
122 {
123 other.key = _key;
124 }
125 if (_value)
126 {
127 other.value = _value;
128 }
129 }
130
131 - (id)copyWithZone:(NSZone *)zone
132 {
133 SECC2MPGenericEventMetric *copy = [[[self class] allocWithZone:zone] init];
134 copy->_key = [_key copyWithZone:zone];
135 copy->_value = [_value copyWithZone:zone];
136 return copy;
137 }
138
139 - (BOOL)isEqual:(id)object
140 {
141 SECC2MPGenericEventMetric *other = (SECC2MPGenericEventMetric *)object;
142 return [other isMemberOfClass:[self class]]
143 &&
144 ((!self->_key && !other->_key) || [self->_key isEqual:other->_key])
145 &&
146 ((!self->_value && !other->_value) || [self->_value isEqual:other->_value])
147 ;
148 }
149
150 - (NSUInteger)hash
151 {
152 return 0
153 ^
154 [self->_key hash]
155 ^
156 [self->_value hash]
157 ;
158 }
159
160 - (void)mergeFrom:(SECC2MPGenericEventMetric *)other
161 {
162 if (other->_key)
163 {
164 [self setKey:other->_key];
165 }
166 if (self->_value && other->_value)
167 {
168 [self->_value mergeFrom:other->_value];
169 }
170 else if (!self->_value && other->_value)
171 {
172 [self setValue:other->_value];
173 }
174 }
175
176 @end
177