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 \*---------------------------------------------------------------------------*/
28 #include "dictionary.H"
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 bool Foam::IOobject::readHeader(Istream& is)
36 Info<< "IOobject::readHeader(Istream&) : reading header for file "
40 // Check Istream not already bad
43 if (rOpt_ == MUST_READ)
45 FatalIOErrorIn("IOobject::readHeader(Istream&)", is)
46 << " stream not open for reading essential object from file "
48 << exit(FatalIOError);
53 SeriousIOErrorIn("IOobject::readHeader(Istream&)", is)
54 << " stream not open for reading from file "
66 && firstToken.isWord()
67 && firstToken.wordToken() == "FoamFile"
70 dictionary headerDict(is);
72 is.version(headerDict.lookup("version"));
73 is.format(headerDict.lookup("format"));
74 headerClassName_ = word(headerDict.lookup("class"));
76 word headerObject(headerDict.lookup("object"));
77 if (IOobject::debug && headerObject != name())
79 IOWarningIn("IOobject::readHeader(Istream&)", is)
80 << " object renamed from "
81 << name() << " to " << headerObject
82 << " for file " << is.name() << endl;
85 // The note entry is optional
86 headerDict.readIfPresent("note", note_);
90 SeriousIOErrorIn("IOobject::readHeader(Istream&)", is)
91 << "First token could not be read or is not the keyword 'FoamFile'"
92 << nl << nl << "Check header is of the form:" << nl << endl;
94 writeHeader(SeriousError);
99 // Check stream is still OK
106 if (rOpt_ == MUST_READ)
108 FatalIOErrorIn("IOobject::readHeader(Istream&)", is)
109 << " stream failure while reading header"
110 << " on line " << is.lineNumber()
111 << " of file " << is.name()
112 << " for essential object" << name()
113 << exit(FatalIOError);
118 Info<< "IOobject::readHeader(Istream&) :"
119 << " stream failure while reading header"
120 << " on line " << is.lineNumber()
121 << " of file " << is.name() << endl;
131 Info<< " .... read" << endl;
138 // ************************************************************************* //