|
35 | 35 |
|
36 | 36 | NS_ASSUME_NONNULL_BEGIN
|
37 | 37 |
|
38 |
| -// Reads and decodes protocol message fields. |
39 |
| -// Subclassing of GPBCodedInputStream is NOT supported. |
| 38 | +/// Reads and decodes protocol message fields. |
| 39 | +/// |
| 40 | +/// The common uses of protocol buffers shouldn't need to use this class. |
| 41 | +/// @c GPBMessage's provide a @c +parseFromData:error: and @c |
| 42 | +/// +parseFromData:extensionRegistry:error: method that will decode a |
| 43 | +/// message for you. |
| 44 | +/// |
| 45 | +/// @note Subclassing of GPBCodedInputStream is NOT supported. |
40 | 46 | @interface GPBCodedInputStream : NSObject
|
41 | 47 |
|
| 48 | +/// Creates a new stream wrapping some data. |
42 | 49 | + (instancetype)streamWithData:(NSData *)data;
|
| 50 | + |
| 51 | +/// Initializes a stream wrapping some data. |
43 | 52 | - (instancetype)initWithData:(NSData *)data;
|
44 | 53 |
|
45 |
| -// Attempt to read a field tag, returning zero if we have reached EOF. |
46 |
| -// Protocol message parsers use this to read tags, since a protocol message |
47 |
| -// may legally end wherever a tag occurs, and zero is not a valid tag number. |
| 54 | +/// Attempt to read a field tag, returning zero if we have reached EOF. |
| 55 | +/// Protocol message parsers use this to read tags, since a protocol message |
| 56 | +/// may legally end wherever a tag occurs, and zero is not a valid tag number. |
48 | 57 | - (int32_t)readTag;
|
49 | 58 |
|
| 59 | +/// Read and return a double. |
50 | 60 | - (double)readDouble;
|
| 61 | +/// Read and return a float. |
51 | 62 | - (float)readFloat;
|
| 63 | +/// Read and return a uint64. |
52 | 64 | - (uint64_t)readUInt64;
|
| 65 | +/// Read and return a uint32. |
53 | 66 | - (uint32_t)readUInt32;
|
| 67 | +/// Read and return an int64. |
54 | 68 | - (int64_t)readInt64;
|
| 69 | +/// Read and return an int32. |
55 | 70 | - (int32_t)readInt32;
|
| 71 | +/// Read and return a fixed64. |
56 | 72 | - (uint64_t)readFixed64;
|
| 73 | +/// Read and return a fixed32. |
57 | 74 | - (uint32_t)readFixed32;
|
| 75 | +/// Read and return an enum (int). |
58 | 76 | - (int32_t)readEnum;
|
| 77 | +/// Read and return a sfixed32. |
59 | 78 | - (int32_t)readSFixed32;
|
| 79 | +/// Read and return a sfixed64. |
60 | 80 | - (int64_t)readSFixed64;
|
| 81 | +/// Read and return a sint32. |
61 | 82 | - (int32_t)readSInt32;
|
| 83 | +/// Read and return a sint64. |
62 | 84 | - (int64_t)readSInt64;
|
| 85 | +/// Read and return a boolean. |
63 | 86 | - (BOOL)readBool;
|
| 87 | +/// Read and return a string. |
64 | 88 | - (NSString *)readString;
|
| 89 | +/// Read and return length delimited data. |
65 | 90 | - (NSData *)readBytes;
|
66 | 91 |
|
67 |
| -// Read an embedded message field value from the stream. |
| 92 | +/// Read an embedded message field value from the stream. |
| 93 | +/// |
| 94 | +/// @param message The message to set fields on as they are read. |
| 95 | +/// @param extensionRegistry An optional extension registry to use to lookup |
| 96 | +/// extensions for @message. |
68 | 97 | - (void)readMessage:(GPBMessage *)message
|
69 |
| - extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry; |
| 98 | + extensionRegistry:(nullable GPBExtensionRegistry *)extensionRegistry; |
70 | 99 |
|
71 |
| -// Reads and discards a single field, given its tag value. Returns NO if the |
72 |
| -// tag is an endgroup tag, in which case nothing is skipped. Otherwise, |
73 |
| -// returns YES. |
| 100 | +/// Reads and discards a single field, given its tag value. |
| 101 | +/// |
| 102 | +/// @param tag The tag number of the field to skip. |
| 103 | +/// |
| 104 | +/// @return NO if the tag is an endgroup tag (in which case nothing is skipped), |
| 105 | +/// YES in all other cases. |
74 | 106 | - (BOOL)skipField:(int32_t)tag;
|
75 | 107 |
|
76 |
| -// Reads and discards an entire message. This will read either until EOF |
77 |
| -// or until an endgroup tag, whichever comes first. |
| 108 | +/// Reads and discards an entire message. This will read either until EOF |
| 109 | +/// or until an endgroup tag, whichever comes first. |
78 | 110 | - (void)skipMessage;
|
79 | 111 |
|
80 |
| -// Verifies that the last call to readTag() returned the given tag value. |
81 |
| -// This is used to verify that a nested group ended with the correct end tag. |
82 |
| -// Throws NSParseErrorException if value does not match the last tag. |
83 |
| -- (void)checkLastTagWas:(int32_t)value; |
| 112 | +/// Verifies that the last call to @c -readTag returned the given tag value. |
| 113 | +/// This is used to verify that a nested group ended with the correct end tag. |
| 114 | +/// Throws @c NSParseErrorException if value does not match the last tag. |
| 115 | +/// |
| 116 | +/// @param expected The tag that was expected. |
| 117 | +- (void)checkLastTagWas:(int32_t)expected; |
84 | 118 |
|
85 | 119 | @end
|
86 | 120 |
|
|
0 commit comments