diff --git a/applications/test/tokenizeTest/tokenizeTest.C b/applications/test/tokenizeTest/tokenizeTest.C index cd80997f61dcdbb79155df2d86a5cd70edbf0764..c8be29cbf35383c4885640547f9a613e16984dec 100644 --- a/applications/test/tokenizeTest/tokenizeTest.C +++ b/applications/test/tokenizeTest/tokenizeTest.C @@ -67,9 +67,15 @@ int main(int argc, char *argv[]) while (is.good()) { token tok(is); + // char ch; + // is.get(ch); + // is.putback(ch); + int lookahead = is.peek(); + if (count == 0) { - Info<< "token: " << tok.info() << endl; + Info<< "token: " << tok.info(); + Info<< " lookahead: '" << char(lookahead) << "'" << endl; } } diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H index fe778fa01031cccb4d0602d913ba61da3ebb6889..0c6bc9d44be70b57ca8a36208cbd55ad985422c7 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.H @@ -137,6 +137,12 @@ public: //- Raw, low-level get character function. inline ISstream& get(char&); + //- Raw, low-level peek function. + // Does not remove the character from the stream. + // Returns the next character in the stream or EOF if the + // end of file is read. + inline int peek(); + //- Raw, low-level getline into a string function. inline ISstream& getLine(string&); diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H b/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H index 1fedf762296079d7b229696baf943bb516735d43..63b1087547ff8feba8529a93964c1cc69587afe8 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstreamI.H @@ -69,6 +69,12 @@ inline Foam::ISstream& Foam::ISstream::get(char& c) } +inline int Foam::ISstream::peek() +{ + return is_.peek(); +} + + inline Foam::ISstream& Foam::ISstream::getLine(string& s) { getline(is_, s);