1111@class GPBUInt32Array;
1212@class GPBUInt64Array;
1313@class GPBUnknownFieldSet;
14+ @class GPBUnknownFields;
1415
1516NS_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+
1633/* *
1734 * Store an unknown field. These are used in conjunction with
1835 * GPBUnknownFieldSet.
@@ -26,48 +43,127 @@ __attribute__((objc_subclassing_restricted))
2643/* * The field number the data is stored under. */
2744@property(nonatomic, readonly, assign) int32_t number;
2845
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+ */
3091@property(nonatomic, readonly, strong) GPBUInt64Array *varintList;
3192
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+ */
3399@property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List;
34100
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+ */
36107@property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List;
37108
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+ */
39115@property(nonatomic, readonly, strong) NSArray <NSData *> *lengthDelimitedList;
40116
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+ */
42123@property(nonatomic, readonly, strong) NSArray <GPBUnknownFieldSet *> *groupList;
43124
44125/* *
45126 * Add a value to the varintList.
46127 *
128+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
129+ * to use with any other type.
130+ *
47131 * @param value The value to add.
48132 **/
49133- (void )addVarint:(uint64_t )value;
50134/* *
51135 * Add a value to the fixed32List.
52136 *
137+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
138+ * to use with any other type.
139+ *
53140 * @param value The value to add.
54141 **/
55142- (void )addFixed32:(uint32_t )value;
56143/* *
57144 * Add a value to the fixed64List.
58145 *
146+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
147+ * to use with any other type.
148+ *
59149 * @param value The value to add.
60150 **/
61151- (void )addFixed64:(uint64_t )value;
62152/* *
63153 * Add a value to the lengthDelimitedList.
64154 *
155+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
156+ * to use with any other type.
157+ *
65158 * @param value The value to add.
66159 **/
67160- (void )addLengthDelimited:(NSData *)value;
68161/* *
69162 * Add a value to the groupList.
70163 *
164+ * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
165+ * to use with any other type.
166+ *
71167 * @param value The value to add.
72168 **/
73169- (void )addGroup:(GPBUnknownFieldSet *)value;
0 commit comments