• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc.  All rights reserved.
3 //
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file or at
6 // https://developers.google.com/open-source/licenses/bsd
7 
8 #import <Foundation/Foundation.h>
9 
10 #import "GPBArray.h"
11 #import "GPBUnknownFieldSet.h"
12 #import "GPBUnknownFields.h"
13 
14 @class GPBUnknownFieldSet;
15 @class GPBUnknownFields;
16 
17 NS_ASSUME_NONNULL_BEGIN
18 
19 typedef NS_ENUM(uint8_t, GPBUnknownFieldType) {
20   GPBUnknownFieldTypeVarint,
21   GPBUnknownFieldTypeFixed32,
22   GPBUnknownFieldTypeFixed64,
23   GPBUnknownFieldTypeLengthDelimited,  // Length prefixed
24   GPBUnknownFieldTypeGroup,            // Tag delimited
25 
26   /**
27    * This type is only used with fields from `GPBUnknownFieldsSet`. Some methods
28    * only work with instances with this type and other apis require the other
29    * type(s). It is a programming error to use the wrong methods.
30    **/
31   GPBUnknownFieldTypeLegacy,
32 };
33 
34 /**
35  * Store an unknown field. These are used in conjunction with GPBUnknownFields.
36  **/
37 __attribute__((objc_subclassing_restricted))
38 @interface GPBUnknownField : NSObject<NSCopying>
39 
40 /** Initialize a field with the given number. */
41 - (instancetype)initWithNumber:(int32_t)number
42     __attribute__((deprecated(
43         "Use the apis on GPBUnknownFields to add new fields instead of making them directly.")));
44 
45 /** The field number the data is stored under. */
46 @property(nonatomic, readonly, assign) int32_t number;
47 
48 /** The type of the field. */
49 @property(nonatomic, readonly, assign) GPBUnknownFieldType type;
50 
51 /**
52  * Fetch the varint value.
53  *
54  * It is a programming error to call this when the `type` is not a varint.
55  */
56 @property(nonatomic, readonly, assign) uint64_t varint;
57 
58 /**
59  * Fetch the fixed32 value.
60  *
61  * It is a programming error to call this when the `type` is not a fixed32.
62  */
63 @property(nonatomic, readonly, assign) uint32_t fixed32;
64 
65 /**
66  * Fetch the fixed64 value.
67  *
68  * It is a programming error to call this when the `type` is not a fixed64.
69  */
70 @property(nonatomic, readonly, assign) uint64_t fixed64;
71 
72 /**
73  * Fetch the length delimited (length prefixed) value.
74  *
75  * It is a programming error to call this when the `type` is not a length
76  * delimited.
77  */
78 @property(nonatomic, readonly, strong, nonnull) NSData *lengthDelimited;
79 
80 /**
81  * Fetch the group (tag delimited) value.
82  *
83  * It is a programming error to call this when the `type` is not a group.
84  */
85 @property(nonatomic, readonly, strong, nonnull) GPBUnknownFields *group;
86 
87 /**
88  * An array of varint values for this field.
89  *
90  * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
91  * to use with any other type.
92  */
93 @property(nonatomic, readonly, strong) GPBUInt64Array *varintList
94     __attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
95 
96 /**
97  * An array of fixed32 values for this field.
98  *
99  * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
100  * to use with any other type.
101  */
102 @property(nonatomic, readonly, strong) GPBUInt32Array *fixed32List
103     __attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
104 
105 /**
106  * An array of fixed64 values for this field.
107  *
108  * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
109  * to use with any other type.
110  */
111 @property(nonatomic, readonly, strong) GPBUInt64Array *fixed64List
112     __attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
113 
114 /**
115  * An array of data values for this field.
116  *
117  * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
118  * to use with any other type.
119  */
120 @property(nonatomic, readonly, strong) NSArray<NSData *> *lengthDelimitedList
121     __attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
122 
123 /**
124  * An array of groups of values for this field.
125  *
126  * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
127  * to use with any other type.
128  */
129 @property(nonatomic, readonly, strong) NSArray<GPBUnknownFieldSet *> *groupList
130     __attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
131 
132 /**
133  * Add a value to the varintList.
134  *
135  * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
136  * to use with any other type.
137  *
138  * @param value The value to add.
139  **/
140 - (void)addVarint:(uint64_t)value
141     __attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
142 
143 /**
144  * Add a value to the fixed32List.
145  *
146  * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
147  * to use with any other type.
148  *
149  * @param value The value to add.
150  **/
151 - (void)addFixed32:(uint32_t)value
152     __attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
153 
154 /**
155  * Add a value to the fixed64List.
156  *
157  * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
158  * to use with any other type.
159  *
160  * @param value The value to add.
161  **/
162 - (void)addFixed64:(uint64_t)value
163     __attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
164 
165 /**
166  * Add a value to the lengthDelimitedList.
167  *
168  * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
169  * to use with any other type.
170  *
171  * @param value The value to add.
172  **/
173 - (void)addLengthDelimited:(NSData *)value
174     __attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
175 
176 /**
177  * Add a value to the groupList.
178  *
179  * Only valid for type == GPBUnknownFieldTypeLegacy, it is a programming error
180  * to use with any other type.
181  *
182  * @param value The value to add.
183  **/
184 - (void)addGroup:(GPBUnknownFieldSet *)value
185     __attribute__((deprecated("See the new apis on GPBUnknownFields and thus reduced api here.")));
186 
187 @end
188 
189 NS_ASSUME_NONNULL_END
190