diff options
author | Thomas Van Lenten <thomasvl@google.com> | 2016-04-01 12:37:05 -0400 |
---|---|---|
committer | Thomas Van Lenten <thomasvl@google.com> | 2016-04-01 12:37:05 -0400 |
commit | a293180541b8121cbea329106e42c66c362acbd3 (patch) | |
tree | 9f098bb05fc577385ed88f4c93078b2f81e823f5 | |
parent | 099ff1ea1400eff8a9f0958f78e44d910dd06e43 (diff) | |
parent | 331cee502296b382ae42b499e2daab59488f91f8 (diff) | |
download | protobuf-a293180541b8121cbea329106e42c66c362acbd3.tar.gz protobuf-a293180541b8121cbea329106e42c66c362acbd3.tar.bz2 protobuf-a293180541b8121cbea329106e42c66c362acbd3.zip |
Merge pull request #1378 from thomasvl/manual_stream_parsing_helpers
Add -position and -isAtEnd for use when manually parsing input streams.
-rw-r--r-- | objectivec/GPBCodedInputStream.h | 9 | ||||
-rw-r--r-- | objectivec/GPBCodedInputStream.m | 8 |
2 files changed, 17 insertions, 0 deletions
diff --git a/objectivec/GPBCodedInputStream.h b/objectivec/GPBCodedInputStream.h index 06198883..d64b64e3 100644 --- a/objectivec/GPBCodedInputStream.h +++ b/objectivec/GPBCodedInputStream.h @@ -109,6 +109,15 @@ NS_ASSUME_NONNULL_BEGIN /// or until an endgroup tag, whichever comes first. - (void)skipMessage; +/// Check to see if the logical end of the stream has been reached. +/// +/// This can return NO when there is no more data, but the current parsing +/// expected more data. +- (BOOL)isAtEnd; + +/// The offset into the stream. +- (size_t)position; + /// Verifies that the last call to @c -readTag returned the given tag value. /// This is used to verify that a nested group ended with the correct end tag. /// Throws @c NSParseErrorException if value does not match the last tag. diff --git a/objectivec/GPBCodedInputStream.m b/objectivec/GPBCodedInputStream.m index fd877838..eaa28e50 100644 --- a/objectivec/GPBCodedInputStream.m +++ b/objectivec/GPBCodedInputStream.m @@ -359,6 +359,14 @@ void GPBCodedInputStreamCheckLastTagWas(GPBCodedInputStreamState *state, } } +- (BOOL)isAtEnd { + return GPBCodedInputStreamIsAtEnd(&state_); +} + +- (size_t)position { + return state_.bufferPos; +} + - (double)readDouble { return GPBCodedInputStreamReadDouble(&state_); } |