GPBCodedInputStream_PackagePrivate.h 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 "GPBCodedInputStream.h"
  11. @class GPBUnknownFieldSet;
  12. @class GPBFieldDescriptor;
  13. typedef struct GPBCodedInputStreamState {
  14. const uint8_t *bytes;
  15. size_t bufferSize;
  16. size_t bufferPos;
  17. // For parsing subsections of an input stream you can put a hard limit on
  18. // how much should be read. Normally the limit is the end of the stream,
  19. // but you can adjust it to anywhere, and if you hit it you will be at the
  20. // end of the stream, until you adjust the limit.
  21. size_t currentLimit;
  22. int32_t lastTag;
  23. NSUInteger recursionDepth;
  24. } GPBCodedInputStreamState;
  25. @interface GPBCodedInputStream () {
  26. @package
  27. struct GPBCodedInputStreamState state_;
  28. NSData *buffer_;
  29. }
  30. // Group support is deprecated, so we hide this interface from users, but
  31. // support for older data.
  32. - (void)readGroup:(int32_t)fieldNumber
  33. message:(GPBMessage *)message
  34. extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry;
  35. // Reads a group field value from the stream and merges it into the given
  36. // UnknownFieldSet.
  37. - (void)readUnknownGroup:(int32_t)fieldNumber message:(GPBUnknownFieldSet *)message;
  38. // Reads a map entry.
  39. - (void)readMapEntry:(id)mapDictionary
  40. extensionRegistry:(id<GPBExtensionRegistry>)extensionRegistry
  41. field:(GPBFieldDescriptor *)field
  42. parentMessage:(GPBMessage *)parentMessage;
  43. @end
  44. CF_EXTERN_C_BEGIN
  45. int32_t GPBCodedInputStreamReadTag(GPBCodedInputStreamState *state);
  46. double GPBCodedInputStreamReadDouble(GPBCodedInputStreamState *state);
  47. float GPBCodedInputStreamReadFloat(GPBCodedInputStreamState *state);
  48. uint64_t GPBCodedInputStreamReadUInt64(GPBCodedInputStreamState *state);
  49. uint32_t GPBCodedInputStreamReadUInt32(GPBCodedInputStreamState *state);
  50. int64_t GPBCodedInputStreamReadInt64(GPBCodedInputStreamState *state);
  51. int32_t GPBCodedInputStreamReadInt32(GPBCodedInputStreamState *state);
  52. uint64_t GPBCodedInputStreamReadFixed64(GPBCodedInputStreamState *state);
  53. uint32_t GPBCodedInputStreamReadFixed32(GPBCodedInputStreamState *state);
  54. int32_t GPBCodedInputStreamReadEnum(GPBCodedInputStreamState *state);
  55. int32_t GPBCodedInputStreamReadSFixed32(GPBCodedInputStreamState *state);
  56. int64_t GPBCodedInputStreamReadSFixed64(GPBCodedInputStreamState *state);
  57. int32_t GPBCodedInputStreamReadSInt32(GPBCodedInputStreamState *state);
  58. int64_t GPBCodedInputStreamReadSInt64(GPBCodedInputStreamState *state);
  59. BOOL GPBCodedInputStreamReadBool(GPBCodedInputStreamState *state);
  60. NSString *GPBCodedInputStreamReadRetainedString(GPBCodedInputStreamState *state)
  61. __attribute((ns_returns_retained));
  62. NSData *GPBCodedInputStreamReadRetainedBytes(GPBCodedInputStreamState *state)
  63. __attribute((ns_returns_retained));
  64. NSData *GPBCodedInputStreamReadRetainedBytesNoCopy(GPBCodedInputStreamState *state)
  65. __attribute((ns_returns_retained));
  66. size_t GPBCodedInputStreamPushLimit(GPBCodedInputStreamState *state, size_t byteLimit);
  67. void GPBCodedInputStreamPopLimit(GPBCodedInputStreamState *state, size_t oldLimit);
  68. size_t GPBCodedInputStreamBytesUntilLimit(GPBCodedInputStreamState *state);
  69. BOOL GPBCodedInputStreamIsAtEnd(GPBCodedInputStreamState *state);
  70. void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, int32_t value);
  71. CF_EXTERN_C_END