1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 void Foam::ITstream::print(Ostream& os) const
34 os << "ITstream : " << name_.c_str();
38 if (begin()->lineNumber() == rbegin()->lineNumber())
40 os << ", line " << begin()->lineNumber() << ", ";
44 os << ", lines " << begin()->lineNumber()
45 << '-' << rbegin()->lineNumber() << ", ";
50 os << ", line " << lineNumber() << ", ";
57 Foam::Istream& Foam::ITstream::read(token& t)
59 // Return the put back token if it exists
60 if (Istream::getBack(t))
62 lineNumber_ = t.lineNumber();
66 if (tokenIndex_ < size())
68 t = operator[](tokenIndex_++);
69 lineNumber_ = t.lineNumber();
71 if (tokenIndex_ == size())
82 "ITstream::read(token& t)",
84 ) << "attempt to read beyond EOF"
85 << exit(FatalIOError);
96 token::undefinedToken.lineNumber()
97 = operator[](size() - 1).lineNumber();
101 token::undefinedToken.lineNumber() = lineNumber();
104 t = token::undefinedToken;
111 Foam::Istream& Foam::ITstream::read(char&)
113 notImplemented("Istream& ITstream::read(char& c)");
118 Foam::Istream& Foam::ITstream::read(word&)
120 notImplemented("Istream& ITstream::read(word&)");
125 Foam::Istream& Foam::ITstream::read(string&)
127 notImplemented("Istream& ITstream::read(string&)");
132 Foam::Istream& Foam::ITstream::read(label&)
134 notImplemented("Istream& ITstream::read(label&)");
139 Foam::Istream& Foam::ITstream::read(floatScalar&)
141 notImplemented("Istream& ITstream::read(floatScalar&)");
146 Foam::Istream& Foam::ITstream::read(doubleScalar&)
148 notImplemented("Istream& ITstream::read(doubleScalar&)");
153 Foam::Istream& Foam::ITstream::read(char*, std::streamsize)
155 notImplemented("Istream& ITstream::read(char*, std::streamsize)");
160 // Rewind the token stream so that it may be read again
161 Foam::Istream& Foam::ITstream::rewind()
167 lineNumber_ = operator[](0).lineNumber();
176 // ************************************************************************* //