GPBMessage_PackagePrivate.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. // This header is private to the ProtobolBuffers library and must NOT be
  8. // included by any sources outside this library. The contents of this file are
  9. // subject to change at any time without notice.
  10. #import "GPBMessage.h"
  11. // TODO: Remove this import. Older generated code use the OSAtomic* apis,
  12. // so anyone that hasn't regenerated says building by having this. After
  13. // enough time has passed, this likely can be removed as folks should have
  14. // regenerated.
  15. #import <libkern/OSAtomic.h>
  16. #import "GPBBootstrap.h"
  17. typedef struct GPBMessage_Storage {
  18. uint32_t _has_storage_[0];
  19. } GPBMessage_Storage;
  20. typedef struct GPBMessage_Storage *GPBMessage_StoragePtr;
  21. @interface GPBMessage () {
  22. @package
  23. // NOTE: Because of the +allocWithZone code using NSAllocateObject(),
  24. // this structure should ideally always be kept pointer aligned where the
  25. // real storage starts is also pointer aligned. The compiler/runtime already
  26. // do this, but it may not be documented.
  27. // A pointer to the actual fields of the subclasses. The actual structure
  28. // pointed to by this pointer will depend on the subclass.
  29. // All of the actual structures will start the same as
  30. // GPBMessage_Storage with _has_storage__ as the first field.
  31. // Kept public because static functions need to access it.
  32. GPBMessage_StoragePtr messageStorage_;
  33. }
  34. // Gets an extension value without autocreating the result if not found. (i.e.
  35. // returns nil if the extension is not set)
  36. - (id)getExistingExtension:(GPBExtensionDescriptor *)extension;
  37. // Parses a message of this type from the input and merges it with this
  38. // message.
  39. //
  40. // `endingTag` should be zero if expected to consume to the end of input, but if
  41. // the input is supposed to be a Group, it should be the endgroup tag to look for.
  42. //
  43. // Warning: This does not verify that all required fields are present in
  44. // the input message.
  45. // NOTE: This will throw if there is an error while parsing.
  46. - (void)mergeFromCodedInputStream:(GPBCodedInputStream *)input
  47. extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
  48. endingTag:(uint32_t)endingTag;
  49. - (void)addUnknownMapEntry:(int32_t)fieldNum value:(NSData *)data;
  50. @end
  51. CF_EXTERN_C_BEGIN
  52. // Returns whether |message| autocreated this message. This is NO if the message
  53. // was not autocreated by |message| or if it has been mutated since
  54. // autocreation.
  55. BOOL GPBWasMessageAutocreatedBy(GPBMessage *message, GPBMessage *parent);
  56. // Call this when you mutate a message. It will cause the message to become
  57. // visible to its autocreator.
  58. void GPBBecomeVisibleToAutocreator(GPBMessage *self);
  59. // Call this when an array/dictionary is mutated so the parent message that
  60. // autocreated it can react.
  61. void GPBAutocreatedArrayModified(GPBMessage *self, id array);
  62. void GPBAutocreatedDictionaryModified(GPBMessage *self, id dictionary);
  63. // Clear the autocreator, if any. Asserts if the autocreator still has an
  64. // autocreated reference to this message.
  65. void GPBClearMessageAutocreator(GPBMessage *self);
  66. // The data (or null) from the unknown fields of a message;
  67. NSData *GPBMessageUnknownFieldsData(GPBMessage *self);
  68. CF_EXTERN_C_END