1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 \*---------------------------------------------------------------------------*/
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33 // Set t to the put back token if there is one and return true,
34 // otherwise return false
35 bool Foam::Istream::getBack(token& t)
39 FatalIOErrorIn("void Istream::getBack(token&)", *this)
40 << "Attempt to get back from bad stream"
41 << exit(FatalIOError);
56 // Keep the put back token
57 void Foam::Istream::putBack(const token& t)
61 FatalIOErrorIn("void Istream::putBack(const token&)", *this)
62 << "Attempt to put back onto bad stream"
63 << exit(FatalIOError);
67 FatalIOErrorIn("void Istream::putBack(const token&)", *this)
68 << "Attempt to put back another token"
69 << exit(FatalIOError);
79 // Functions for reading object delimiters ( ... )
81 Foam::Istream& Foam::Istream::readBegin(const char* funcName)
83 token delimiter(*this);
84 if (delimiter != token::BEGIN_LIST)
87 FatalIOErrorIn("Istream::readBegin(const char*)", *this)
88 << "Expected a '" << token::BEGIN_LIST
89 << "' while reading " << funcName
90 << ", found " << delimiter.info()
91 << exit(FatalIOError);
98 Foam::Istream& Foam::Istream::readEnd(const char* funcName)
100 token delimiter(*this);
101 if (delimiter != token::END_LIST)
104 FatalIOErrorIn("Istream::readEnd(const char*)", *this)
105 << "Expected a '" << token::END_LIST
106 << "' while reading " << funcName
107 << ", found " << delimiter.info()
108 << exit(FatalIOError);
115 Foam::Istream& Foam::Istream::readEndBegin(const char* funcName)
118 return readBegin(funcName);
122 // Functions for reading List delimiters ( ... ) or { ... }
124 char Foam::Istream::readBeginList(const char* funcName)
126 token delimiter(*this);
128 if (delimiter != token::BEGIN_LIST && delimiter != token::BEGIN_BLOCK)
131 FatalIOErrorIn("Istream::readBeginList(const char*)", *this)
132 << "Expected a '" << token::BEGIN_LIST
133 << "' or a '" << token::BEGIN_BLOCK
134 << "' while reading " << funcName
135 << ", found " << delimiter.info()
136 << exit(FatalIOError);
141 return delimiter.pToken();
145 char Foam::Istream::readEndList(const char* funcName)
147 token delimiter(*this);
149 if (delimiter != token::END_LIST && delimiter != token::END_BLOCK)
152 FatalIOErrorIn("Istream::readEndList(const char*)", *this)
153 << "Expected a '" << token::END_LIST
154 << "' or a '" << token::END_BLOCK
155 << "' while reading " << funcName
156 << ", found " << delimiter.info()
157 << exit(FatalIOError);
162 return delimiter.pToken();
166 Foam::Istream& Foam::Istream::operator()() const
170 check("Istream::operator()");
174 return const_cast<Istream&>(*this);
178 // ************************************************************************* //