GPBCodedInputStream_PackagePrivate.h 4.0 KB

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