Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 1 | // Protocol Buffers - Google's data interchange format |
| 2 | // Copyright 2008 Google Inc. All rights reserved. |
| 3 | // https://developers.google.com/protocol-buffers/ |
| 4 | // |
| 5 | // Redistribution and use in source and binary forms, with or without |
| 6 | // modification, are permitted provided that the following conditions are |
| 7 | // met: |
| 8 | // |
| 9 | // * Redistributions of source code must retain the above copyright |
| 10 | // notice, this list of conditions and the following disclaimer. |
| 11 | // * Redistributions in binary form must reproduce the above |
| 12 | // copyright notice, this list of conditions and the following disclaimer |
| 13 | // in the documentation and/or other materials provided with the |
| 14 | // distribution. |
| 15 | // * Neither the name of Google Inc. nor the names of its |
| 16 | // contributors may be used to endorse or promote products derived from |
| 17 | // this software without specific prior written permission. |
| 18 | // |
| 19 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 20 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 21 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 22 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 23 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 24 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 25 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | |
| 31 | #import <Foundation/Foundation.h> |
| 32 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 33 | #import "GPBArray.h" |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 34 | #import "GPBMessage.h" |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 35 | #import "GPBRuntimeTypes.h" |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 36 | |
Thomas Van Lenten | 3c8e959 | 2020-04-13 10:49:16 -0400 | [diff] [blame] | 37 | @class GPBOneofDescriptor; |
| 38 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 39 | CF_EXTERN_C_BEGIN |
| 40 | |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 41 | NS_ASSUME_NONNULL_BEGIN |
| 42 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 43 | /** |
| 44 | * Generates a string that should be a valid "TextFormat" for the C++ version |
| 45 | * of Protocol Buffers. |
| 46 | * |
| 47 | * @param message The message to generate from. |
| 48 | * @param lineIndent A string to use as the prefix for all lines generated. Can |
| 49 | * be nil if no extra indent is needed. |
| 50 | * |
| 51 | * @return An NSString with the TextFormat of the message. |
| 52 | **/ |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 53 | NSString *GPBTextFormatForMessage(GPBMessage *message, |
| 54 | NSString * __nullable lineIndent); |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 55 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 56 | /** |
| 57 | * Generates a string that should be a valid "TextFormat" for the C++ version |
| 58 | * of Protocol Buffers. |
| 59 | * |
| 60 | * @param unknownSet The unknown field set to generate from. |
| 61 | * @param lineIndent A string to use as the prefix for all lines generated. Can |
| 62 | * be nil if no extra indent is needed. |
| 63 | * |
| 64 | * @return An NSString with the TextFormat of the unknown field set. |
| 65 | **/ |
Thomas Van Lenten | c27833b | 2015-12-07 10:49:30 -0500 | [diff] [blame] | 66 | NSString *GPBTextFormatForUnknownFieldSet(GPBUnknownFieldSet * __nullable unknownSet, |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 67 | NSString * __nullable lineIndent); |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 68 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 69 | /** |
| 70 | * Checks if the given field number is set on a message. |
| 71 | * |
| 72 | * @param self The message to check. |
| 73 | * @param fieldNumber The field number to check. |
| 74 | * |
| 75 | * @return YES if the field number is set on the given message. |
| 76 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 77 | BOOL GPBMessageHasFieldNumberSet(GPBMessage *self, uint32_t fieldNumber); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 78 | |
| 79 | /** |
| 80 | * Checks if the given field is set on a message. |
| 81 | * |
| 82 | * @param self The message to check. |
| 83 | * @param field The field to check. |
| 84 | * |
| 85 | * @return YES if the field is set on the given message. |
| 86 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 87 | BOOL GPBMessageHasFieldSet(GPBMessage *self, GPBFieldDescriptor *field); |
| 88 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 89 | /** |
| 90 | * Clears the given field for the given message. |
| 91 | * |
| 92 | * @param self The message for which to clear the field. |
| 93 | * @param field The field to clear. |
| 94 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 95 | void GPBClearMessageField(GPBMessage *self, GPBFieldDescriptor *field); |
| 96 | |
Thomas Van Lenten | 3c8e959 | 2020-04-13 10:49:16 -0400 | [diff] [blame] | 97 | /** |
Thomas Van Lenten | dddeed2 | 2020-04-24 13:40:59 -0400 | [diff] [blame] | 98 | * Clears the given oneof field for the given message. |
Thomas Van Lenten | 3c8e959 | 2020-04-13 10:49:16 -0400 | [diff] [blame] | 99 | * |
| 100 | * @param self The message for which to clear the field. |
| 101 | * @param oneof The oneof to clear. |
| 102 | **/ |
| 103 | void GPBClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof); |
| 104 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 105 | //%PDDM-EXPAND GPB_ACCESSORS() |
| 106 | // This block of code is generated, do not edit it directly. |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 107 | // clang-format off |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 108 | |
| 109 | |
| 110 | // |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 111 | // Get/Set a given field from/to a message. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 112 | // |
| 113 | |
| 114 | // Single Fields |
| 115 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 116 | /** |
| 117 | * Gets the value of a bytes field. |
| 118 | * |
| 119 | * @param self The message from which to get the field. |
| 120 | * @param field The field to get. |
| 121 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 122 | NSData *GPBGetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 123 | |
| 124 | /** |
| 125 | * Sets the value of a bytes field. |
| 126 | * |
| 127 | * @param self The message into which to set the field. |
| 128 | * @param field The field to set. |
| 129 | * @param value The to set in the field. |
| 130 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 131 | void GPBSetMessageBytesField(GPBMessage *self, GPBFieldDescriptor *field, NSData *value); |
| 132 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 133 | /** |
| 134 | * Gets the value of a string field. |
| 135 | * |
| 136 | * @param self The message from which to get the field. |
| 137 | * @param field The field to get. |
| 138 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 139 | NSString *GPBGetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 140 | |
| 141 | /** |
| 142 | * Sets the value of a string field. |
| 143 | * |
| 144 | * @param self The message into which to set the field. |
| 145 | * @param field The field to set. |
| 146 | * @param value The to set in the field. |
| 147 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 148 | void GPBSetMessageStringField(GPBMessage *self, GPBFieldDescriptor *field, NSString *value); |
| 149 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 150 | /** |
| 151 | * Gets the value of a message field. |
| 152 | * |
| 153 | * @param self The message from which to get the field. |
| 154 | * @param field The field to get. |
| 155 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 156 | GPBMessage *GPBGetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 157 | |
| 158 | /** |
| 159 | * Sets the value of a message field. |
| 160 | * |
| 161 | * @param self The message into which to set the field. |
| 162 | * @param field The field to set. |
| 163 | * @param value The to set in the field. |
| 164 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 165 | void GPBSetMessageMessageField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value); |
| 166 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 167 | /** |
| 168 | * Gets the value of a group field. |
| 169 | * |
| 170 | * @param self The message from which to get the field. |
| 171 | * @param field The field to get. |
| 172 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 173 | GPBMessage *GPBGetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 174 | |
| 175 | /** |
| 176 | * Sets the value of a group field. |
| 177 | * |
| 178 | * @param self The message into which to set the field. |
| 179 | * @param field The field to set. |
| 180 | * @param value The to set in the field. |
| 181 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 182 | void GPBSetMessageGroupField(GPBMessage *self, GPBFieldDescriptor *field, GPBMessage *value); |
| 183 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 184 | /** |
| 185 | * Gets the value of a bool field. |
| 186 | * |
| 187 | * @param self The message from which to get the field. |
| 188 | * @param field The field to get. |
| 189 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 190 | BOOL GPBGetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 191 | |
| 192 | /** |
| 193 | * Sets the value of a bool field. |
| 194 | * |
| 195 | * @param self The message into which to set the field. |
| 196 | * @param field The field to set. |
| 197 | * @param value The to set in the field. |
| 198 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 199 | void GPBSetMessageBoolField(GPBMessage *self, GPBFieldDescriptor *field, BOOL value); |
| 200 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 201 | /** |
| 202 | * Gets the value of an int32 field. |
| 203 | * |
| 204 | * @param self The message from which to get the field. |
| 205 | * @param field The field to get. |
| 206 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 207 | int32_t GPBGetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 208 | |
| 209 | /** |
| 210 | * Sets the value of an int32 field. |
| 211 | * |
| 212 | * @param self The message into which to set the field. |
| 213 | * @param field The field to set. |
| 214 | * @param value The to set in the field. |
| 215 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 216 | void GPBSetMessageInt32Field(GPBMessage *self, GPBFieldDescriptor *field, int32_t value); |
| 217 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 218 | /** |
| 219 | * Gets the value of an uint32 field. |
| 220 | * |
| 221 | * @param self The message from which to get the field. |
| 222 | * @param field The field to get. |
| 223 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 224 | uint32_t GPBGetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 225 | |
| 226 | /** |
| 227 | * Sets the value of an uint32 field. |
| 228 | * |
| 229 | * @param self The message into which to set the field. |
| 230 | * @param field The field to set. |
| 231 | * @param value The to set in the field. |
| 232 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 233 | void GPBSetMessageUInt32Field(GPBMessage *self, GPBFieldDescriptor *field, uint32_t value); |
| 234 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 235 | /** |
| 236 | * Gets the value of an int64 field. |
| 237 | * |
| 238 | * @param self The message from which to get the field. |
| 239 | * @param field The field to get. |
| 240 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 241 | int64_t GPBGetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 242 | |
| 243 | /** |
| 244 | * Sets the value of an int64 field. |
| 245 | * |
| 246 | * @param self The message into which to set the field. |
| 247 | * @param field The field to set. |
| 248 | * @param value The to set in the field. |
| 249 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 250 | void GPBSetMessageInt64Field(GPBMessage *self, GPBFieldDescriptor *field, int64_t value); |
| 251 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 252 | /** |
| 253 | * Gets the value of an uint64 field. |
| 254 | * |
| 255 | * @param self The message from which to get the field. |
| 256 | * @param field The field to get. |
| 257 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 258 | uint64_t GPBGetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 259 | |
| 260 | /** |
| 261 | * Sets the value of an uint64 field. |
| 262 | * |
| 263 | * @param self The message into which to set the field. |
| 264 | * @param field The field to set. |
| 265 | * @param value The to set in the field. |
| 266 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 267 | void GPBSetMessageUInt64Field(GPBMessage *self, GPBFieldDescriptor *field, uint64_t value); |
| 268 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 269 | /** |
| 270 | * Gets the value of a float field. |
| 271 | * |
| 272 | * @param self The message from which to get the field. |
| 273 | * @param field The field to get. |
| 274 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 275 | float GPBGetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 276 | |
| 277 | /** |
| 278 | * Sets the value of a float field. |
| 279 | * |
| 280 | * @param self The message into which to set the field. |
| 281 | * @param field The field to set. |
| 282 | * @param value The to set in the field. |
| 283 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 284 | void GPBSetMessageFloatField(GPBMessage *self, GPBFieldDescriptor *field, float value); |
| 285 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 286 | /** |
| 287 | * Gets the value of a double field. |
| 288 | * |
| 289 | * @param self The message from which to get the field. |
| 290 | * @param field The field to get. |
| 291 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 292 | double GPBGetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 293 | |
| 294 | /** |
| 295 | * Sets the value of a double field. |
| 296 | * |
| 297 | * @param self The message into which to set the field. |
| 298 | * @param field The field to set. |
| 299 | * @param value The to set in the field. |
| 300 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 301 | void GPBSetMessageDoubleField(GPBMessage *self, GPBFieldDescriptor *field, double value); |
| 302 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 303 | /** |
| 304 | * Gets the given enum field of a message. For proto3, if the value isn't a |
| 305 | * member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned. |
| 306 | * GPBGetMessageRawEnumField will bypass the check and return whatever value |
| 307 | * was set. |
| 308 | * |
| 309 | * @param self The message from which to get the field. |
| 310 | * @param field The field to get. |
| 311 | * |
| 312 | * @return The enum value for the given field. |
| 313 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 314 | int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 315 | |
| 316 | /** |
| 317 | * Set the given enum field of a message. You can only set values that are |
| 318 | * members of the enum. |
| 319 | * |
| 320 | * @param self The message into which to set the field. |
| 321 | * @param field The field to set. |
| 322 | * @param value The enum value to set in the field. |
| 323 | **/ |
| 324 | void GPBSetMessageEnumField(GPBMessage *self, |
| 325 | GPBFieldDescriptor *field, |
| 326 | int32_t value); |
| 327 | |
| 328 | /** |
| 329 | * Get the given enum field of a message. No check is done to ensure the value |
| 330 | * was defined in the enum. |
| 331 | * |
| 332 | * @param self The message from which to get the field. |
| 333 | * @param field The field to get. |
| 334 | * |
| 335 | * @return The raw enum value for the given field. |
| 336 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 337 | int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 338 | |
| 339 | /** |
| 340 | * Set the given enum field of a message. You can set the value to anything, |
| 341 | * even a value that is not a member of the enum. |
| 342 | * |
| 343 | * @param self The message into which to set the field. |
| 344 | * @param field The field to set. |
| 345 | * @param value The raw enum value to set in the field. |
| 346 | **/ |
| 347 | void GPBSetMessageRawEnumField(GPBMessage *self, |
| 348 | GPBFieldDescriptor *field, |
| 349 | int32_t value); |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 350 | |
| 351 | // Repeated Fields |
| 352 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 353 | /** |
| 354 | * Gets the value of a repeated field. |
| 355 | * |
| 356 | * @param self The message from which to get the field. |
| 357 | * @param field The repeated field to get. |
| 358 | * |
| 359 | * @return A GPB*Array or an NSMutableArray based on the field's type. |
| 360 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 361 | id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 362 | |
| 363 | /** |
| 364 | * Sets the value of a repeated field. |
| 365 | * |
| 366 | * @param self The message into which to set the field. |
| 367 | * @param field The field to set. |
| 368 | * @param array A GPB*Array or NSMutableArray based on the field's type. |
| 369 | **/ |
| 370 | void GPBSetMessageRepeatedField(GPBMessage *self, |
| 371 | GPBFieldDescriptor *field, |
| 372 | id array); |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 373 | |
| 374 | // Map Fields |
| 375 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 376 | /** |
| 377 | * Gets the value of a map<> field. |
| 378 | * |
| 379 | * @param self The message from which to get the field. |
| 380 | * @param field The repeated field to get. |
| 381 | * |
| 382 | * @return A GPB*Dictionary or NSMutableDictionary based on the field's type. |
| 383 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 384 | id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 385 | |
| 386 | /** |
| 387 | * Sets the value of a map<> field. |
| 388 | * |
| 389 | * @param self The message into which to set the field. |
| 390 | * @param field The field to set. |
| 391 | * @param dictionary A GPB*Dictionary or NSMutableDictionary based on the |
| 392 | * field's type. |
| 393 | **/ |
| 394 | void GPBSetMessageMapField(GPBMessage *self, |
| 395 | GPBFieldDescriptor *field, |
| 396 | id dictionary); |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 397 | |
Dave MacLachlan | ab48ecf | 2020-01-20 13:47:20 -0800 | [diff] [blame] | 398 | // clang-format on |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 399 | //%PDDM-EXPAND-END GPB_ACCESSORS() |
| 400 | |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 401 | /** |
| 402 | * Returns an empty NSData to assign to byte fields when you wish to assign them |
| 403 | * to empty. Prevents allocating a lot of little [NSData data] objects. |
| 404 | **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 405 | NSData *GPBEmptyNSData(void) __attribute__((pure)); |
| 406 | |
Thomas Van Lenten | d071766 | 2017-02-23 12:29:00 -0500 | [diff] [blame] | 407 | /** |
| 408 | * Drops the `unknownFields` from the given message and from all sub message. |
| 409 | **/ |
| 410 | void GPBMessageDropUnknownFieldsRecursively(GPBMessage *message); |
| 411 | |
Thomas Van Lenten | 8c88957 | 2015-06-16 16:45:14 -0400 | [diff] [blame] | 412 | NS_ASSUME_NONNULL_END |
| 413 | |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 414 | CF_EXTERN_C_END |
| 415 | |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 416 | |
| 417 | //%PDDM-DEFINE GPB_ACCESSORS() |
Thomas Van Lenten | 30650d8 | 2015-05-01 08:57:16 -0400 | [diff] [blame] | 418 | //% |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 419 | //%// |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 420 | //%// Get/Set a given field from/to a message. |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 421 | //%// |
| 422 | //% |
| 423 | //%// Single Fields |
| 424 | //% |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 425 | //%GPB_ACCESSOR_SINGLE_FULL(Bytes, NSData, , *) |
| 426 | //%GPB_ACCESSOR_SINGLE_FULL(String, NSString, , *) |
| 427 | //%GPB_ACCESSOR_SINGLE_FULL(Message, GPBMessage, , *) |
| 428 | //%GPB_ACCESSOR_SINGLE_FULL(Group, GPBMessage, , *) |
| 429 | //%GPB_ACCESSOR_SINGLE(Bool, BOOL, ) |
| 430 | //%GPB_ACCESSOR_SINGLE(Int32, int32_t, n) |
| 431 | //%GPB_ACCESSOR_SINGLE(UInt32, uint32_t, n) |
| 432 | //%GPB_ACCESSOR_SINGLE(Int64, int64_t, n) |
| 433 | //%GPB_ACCESSOR_SINGLE(UInt64, uint64_t, n) |
| 434 | //%GPB_ACCESSOR_SINGLE(Float, float, ) |
| 435 | //%GPB_ACCESSOR_SINGLE(Double, double, ) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 436 | //%/** |
| 437 | //% * Gets the given enum field of a message. For proto3, if the value isn't a |
| 438 | //% * member of the enum, @c kGPBUnrecognizedEnumeratorValue will be returned. |
| 439 | //% * GPBGetMessageRawEnumField will bypass the check and return whatever value |
| 440 | //% * was set. |
| 441 | //% * |
| 442 | //% * @param self The message from which to get the field. |
| 443 | //% * @param field The field to get. |
| 444 | //% * |
| 445 | //% * @return The enum value for the given field. |
| 446 | //% **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 447 | //%int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 448 | //% |
| 449 | //%/** |
| 450 | //% * Set the given enum field of a message. You can only set values that are |
| 451 | //% * members of the enum. |
| 452 | //% * |
| 453 | //% * @param self The message into which to set the field. |
| 454 | //% * @param field The field to set. |
| 455 | //% * @param value The enum value to set in the field. |
| 456 | //% **/ |
| 457 | //%void GPBSetMessageEnumField(GPBMessage *self, |
| 458 | //% GPBFieldDescriptor *field, |
| 459 | //% int32_t value); |
| 460 | //% |
| 461 | //%/** |
| 462 | //% * Get the given enum field of a message. No check is done to ensure the value |
| 463 | //% * was defined in the enum. |
| 464 | //% * |
| 465 | //% * @param self The message from which to get the field. |
| 466 | //% * @param field The field to get. |
| 467 | //% * |
| 468 | //% * @return The raw enum value for the given field. |
| 469 | //% **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 470 | //%int32_t GPBGetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 471 | //% |
| 472 | //%/** |
| 473 | //% * Set the given enum field of a message. You can set the value to anything, |
| 474 | //% * even a value that is not a member of the enum. |
| 475 | //% * |
| 476 | //% * @param self The message into which to set the field. |
| 477 | //% * @param field The field to set. |
| 478 | //% * @param value The raw enum value to set in the field. |
| 479 | //% **/ |
| 480 | //%void GPBSetMessageRawEnumField(GPBMessage *self, |
| 481 | //% GPBFieldDescriptor *field, |
| 482 | //% int32_t value); |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 483 | //% |
| 484 | //%// Repeated Fields |
| 485 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 486 | //%/** |
| 487 | //% * Gets the value of a repeated field. |
| 488 | //% * |
| 489 | //% * @param self The message from which to get the field. |
| 490 | //% * @param field The repeated field to get. |
| 491 | //% * |
| 492 | //% * @return A GPB*Array or an NSMutableArray based on the field's type. |
| 493 | //% **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 494 | //%id GPBGetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 495 | //% |
| 496 | //%/** |
| 497 | //% * Sets the value of a repeated field. |
| 498 | //% * |
| 499 | //% * @param self The message into which to set the field. |
| 500 | //% * @param field The field to set. |
| 501 | //% * @param array A GPB*Array or NSMutableArray based on the field's type. |
| 502 | //% **/ |
| 503 | //%void GPBSetMessageRepeatedField(GPBMessage *self, |
| 504 | //% GPBFieldDescriptor *field, |
| 505 | //% id array); |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 506 | //% |
| 507 | //%// Map Fields |
| 508 | //% |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 509 | //%/** |
| 510 | //% * Gets the value of a map<> field. |
| 511 | //% * |
| 512 | //% * @param self The message from which to get the field. |
| 513 | //% * @param field The repeated field to get. |
| 514 | //% * |
| 515 | //% * @return A GPB*Dictionary or NSMutableDictionary based on the field's type. |
| 516 | //% **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 517 | //%id GPBGetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 518 | //% |
| 519 | //%/** |
| 520 | //% * Sets the value of a map<> field. |
| 521 | //% * |
| 522 | //% * @param self The message into which to set the field. |
| 523 | //% * @param field The field to set. |
| 524 | //% * @param dictionary A GPB*Dictionary or NSMutableDictionary based on the |
| 525 | //% * field's type. |
| 526 | //% **/ |
| 527 | //%void GPBSetMessageMapField(GPBMessage *self, |
| 528 | //% GPBFieldDescriptor *field, |
| 529 | //% id dictionary); |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 530 | //% |
| 531 | |
Thomas Van Lenten | 36650a0 | 2016-03-07 12:07:03 -0500 | [diff] [blame] | 532 | //%PDDM-DEFINE GPB_ACCESSOR_SINGLE(NAME, TYPE, AN) |
| 533 | //%GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, ) |
| 534 | //%PDDM-DEFINE GPB_ACCESSOR_SINGLE_FULL(NAME, TYPE, AN, TisP) |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 535 | //%/** |
| 536 | //% * Gets the value of a##AN NAME$L field. |
| 537 | //% * |
| 538 | //% * @param self The message from which to get the field. |
| 539 | //% * @param field The field to get. |
| 540 | //% **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 541 | //%TYPE TisP##GPBGetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field); |
Sergio Campamá | 32fadc0 | 2016-08-08 07:15:02 -0700 | [diff] [blame] | 542 | //% |
| 543 | //%/** |
| 544 | //% * Sets the value of a##AN NAME$L field. |
| 545 | //% * |
| 546 | //% * @param self The message into which to set the field. |
| 547 | //% * @param field The field to set. |
| 548 | //% * @param value The to set in the field. |
| 549 | //% **/ |
Thomas Van Lenten | d846b0b | 2015-06-08 16:24:57 -0400 | [diff] [blame] | 550 | //%void GPBSetMessage##NAME##Field(GPBMessage *self, GPBFieldDescriptor *field, TYPE TisP##value); |
| 551 | //% |