diff options
author | Kenneth Heafield <github@kheafield.com> | 2020-02-25 19:02:10 +0300 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2020-02-25 19:02:10 +0300 |
commit | 2fc4130cd79949df2545f3ab48798b8634a00a79 (patch) | |
tree | 36f5899f74afcca804ae697dfdeda7d5edfb7f89 | |
parent | 0929c4d225a3ab85fef68d9f44200838d6561992 (diff) |
Add peek function for consistency with preprocess
-rw-r--r-- | util/file_piece.hh | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/util/file_piece.hh b/util/file_piece.hh index 042a78e..fc60dd1 100644 --- a/util/file_piece.hh +++ b/util/file_piece.hh @@ -81,12 +81,18 @@ class FilePiece { return LineIterator(); } - char get() { + char peek() { if (position_ == position_end_) { Shift(); if (at_end_) throw EndOfFileException(); } - return *(position_++); + return *position_; + } + + char get() { + char ret = peek(); + ++position_; + return ret; } // Leaves the delimiter, if any, to be returned by get(). Delimiters defined by isspace(). |