11
11
@class GPBUInt32Array;
12
12
@class GPBUInt64Array;
13
13
@class GPBUnknownFieldSet;
14
+ @class GPBUnknownFields;
14
15
15
16
NS_ASSUME_NONNULL_BEGIN
17
+
18
+ typedef NS_ENUM (uint8_t , GPBUnknownFieldType) {
19
+ GPBUnknownFieldTypeVarint,
20
+ GPBUnknownFieldTypeFixed32,
21
+ GPBUnknownFieldTypeFixed64,
22
+ GPBUnknownFieldTypeLengthDelimited, // Length prefixed
23
+ GPBUnknownFieldTypeGroup, // Tag delimited
24
+
25
+ /* *
26
+ * This type is only used with fields from `GPBUnknownFieldsSet`. Some methods
27
+ * only work with instances with this type and other apis require the other
28
+ * type(s). It is a programming error to use the wrong methods.
29
+ **/
30
+ GPBUnknownFieldTypeLegacy,
31
+ };
32
+
16
33
/* *
17
34
* Store an unknown field. These are used in conjunction with
18
35
* GPBUnknownFieldSet.
@@ -26,48 +43,127 @@ __attribute__((objc_subclassing_restricted))
26
43
/* * The field number the data is stored under. */
27
44
@property(nonatomic, readonly, assign) int32_t number;
28
45
29
- /* * An array of varint values for this field. */
46
+ /* * The type of the field. */
47
+ @property(nonatomic, readonly, assign) GPBUnknownFieldType type;
48
+
49
+ /* *
50
+ * Fetch the varint value.
51
+ *
52
+ * It is a programming error to call this when the `type` is not a varint.
53
+ */
54
+ @property(nonatomic, readonly, assign) uint64_t varint;
55
+
56
+ /* *
57
+ * Fetch the fixed32 value.
58
+ *
59
+ * It is a programming error to call this when the `type` is not a fixed32.
60
+ */
61
+ @property(nonatomic, readonly, assign) uint32_t fixed32;
62
+
63
+ /* *
64
+ * Fetch the fixed64 value.
65
+ *
66
+ * It is a programming error to call this when the `type` is not a fixed64.
67
+ */
68
+ @property(nonatomic, readonly, assign) uint64_t fixed64;
69
+
70
+ /* *
71
+ * Fetch the length delimited (length prefixed) value.
72
+ *
73
+ * It is a programming error to call this when the `type` is not a length
74
+ * delimited.
75
+ */
76
+ @property(nonatomic, readonly, strong, nonnull) NSData *lengthDelimited;
77
+
78
+ /* *
79
+ * Fetch the group (tag delimited) value.
80
+ *
81
+ * It is a programming error to call this when the `type` is not a group.
82
+ */
83
+ @property(nonatomic, readonly, strong, nonnull) GPBUnknownFields *group;
84
+
85
+ /* *
86
+ * An array of varint values for this field.
87
+ *
88
+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
89
+ * to use with any other type.
90
+ */
30
91
@property(nonatomic, readonly, strong) GPBUInt64Array *varintList;
31
92
32
- /* * An array of fixed32 values for this field. */
93
+ /* *
94
+ * An array of fixed32 values for this field.
95
+ *
96
+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
97
+ * to use with any other type.
98
+ */
33
99
@property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List;
34
100
35
- /* * An array of fixed64 values for this field. */
101
+ /* *
102
+ * An array of fixed64 values for this field.
103
+ *
104
+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
105
+ * to use with any other type.
106
+ */
36
107
@property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List;
37
108
38
- /* * An array of data values for this field. */
109
+ /* *
110
+ * An array of data values for this field.
111
+ *
112
+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
113
+ * to use with any other type.
114
+ */
39
115
@property(nonatomic, readonly, strong) NSArray <NSData *> *lengthDelimitedList;
40
116
41
- /* * An array of groups of values for this field. */
117
+ /* *
118
+ * An array of groups of values for this field.
119
+ *
120
+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
121
+ * to use with any other type.
122
+ */
42
123
@property(nonatomic, readonly, strong) NSArray <GPBUnknownFieldSet *> *groupList;
43
124
44
125
/* *
45
126
* Add a value to the varintList.
46
127
*
128
+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
129
+ * to use with any other type.
130
+ *
47
131
* @param value The value to add.
48
132
**/
49
133
- (void )addVarint:(uint64_t )value;
50
134
/* *
51
135
* Add a value to the fixed32List.
52
136
*
137
+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
138
+ * to use with any other type.
139
+ *
53
140
* @param value The value to add.
54
141
**/
55
142
- (void )addFixed32:(uint32_t )value;
56
143
/* *
57
144
* Add a value to the fixed64List.
58
145
*
146
+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
147
+ * to use with any other type.
148
+ *
59
149
* @param value The value to add.
60
150
**/
61
151
- (void )addFixed64:(uint64_t )value;
62
152
/* *
63
153
* Add a value to the lengthDelimitedList.
64
154
*
155
+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
156
+ * to use with any other type.
157
+ *
65
158
* @param value The value to add.
66
159
**/
67
160
- (void )addLengthDelimited:(NSData *)value;
68
161
/* *
69
162
* Add a value to the groupList.
70
163
*
164
+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
165
+ * to use with any other type.
166
+ *
71
167
* @param value The value to add.
72
168
**/
73
169
- (void )addGroup:(GPBUnknownFieldSet *)value;
0 commit comments