GPBUnknownField.h 5.8 KB

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