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