1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
27 #include "dictionary.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 bool Foam::IOobject::readHeader(Istream& is)
35 Info<< "IOobject::readHeader(Istream&) : reading header for file "
39 // Check Istream not already bad
42 if (rOpt_ == MUST_READ)
44 FatalIOErrorIn("IOobject::readHeader(Istream&)", is)
45 << " stream not open for reading essential object from file "
47 << exit(FatalIOError);
52 SeriousIOErrorIn("IOobject::readHeader(Istream&)", is)
53 << " stream not open for reading from file "
65 && firstToken.isWord()
66 && firstToken.wordToken() == "FoamFile"
69 dictionary headerDict(is);
71 is.version(headerDict.lookup("version"));
72 is.format(headerDict.lookup("format"));
73 headerClassName_ = word(headerDict.lookup("class"));
75 word headerObject(headerDict.lookup("object"));
76 if (IOobject::debug && headerObject != name())
78 IOWarningIn("IOobject::readHeader(Istream&)", is)
79 << " object renamed from "
80 << name() << " to " << headerObject
81 << " for file " << is.name() << endl;
84 // The note entry is optional
85 headerDict.readIfPresent("note", note_);
89 SeriousIOErrorIn("IOobject::readHeader(Istream&)", is)
90 << "First token could not be read or is not the keyword 'FoamFile'"
91 << nl << nl << "Check header is of the form:" << nl << endl;
98 // Check stream is still OK
105 if (rOpt_ == MUST_READ)
107 FatalIOErrorIn("IOobject::readHeader(Istream&)", is)
108 << " stream failure while reading header"
109 << " on line " << is.lineNumber()
110 << " of file " << is.name()
111 << " for essential object" << name()
112 << exit(FatalIOError);
117 Info<< "IOobject::readHeader(Istream&) :"
118 << " stream failure while reading header"
119 << " on line " << is.lineNumber()
120 << " of file " << is.name() << endl;
130 Info<< " .... read" << endl;
137 // ************************************************************************* //