Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "IOobject.H"
00027 #include <OpenFOAM/dictionary.H>
00028
00029
00030
00031 bool Foam::IOobject::readHeader(Istream& is)
00032 {
00033 if (IOobject::debug)
00034 {
00035 Info<< "IOobject::readHeader(Istream&) : reading header for file "
00036 << is.name() << endl;
00037 }
00038
00039
00040 if (!is.good())
00041 {
00042 if (rOpt_ == MUST_READ)
00043 {
00044 FatalIOErrorIn("IOobject::readHeader(Istream&)", is)
00045 << " stream not open for reading essential object from file "
00046 << is.name()
00047 << exit(FatalIOError);
00048 }
00049
00050 if (IOobject::debug)
00051 {
00052 SeriousIOErrorIn("IOobject::readHeader(Istream&)", is)
00053 << " stream not open for reading from file "
00054 << is.name() << endl;
00055 }
00056
00057 return false;
00058 }
00059
00060 token firstToken(is);
00061
00062 if
00063 (
00064 is.good()
00065 && firstToken.isWord()
00066 && firstToken.wordToken() == "FoamFile"
00067 )
00068 {
00069 dictionary headerDict(is);
00070
00071 is.version(headerDict.lookup("version"));
00072 is.format(headerDict.lookup("format"));
00073 headerClassName_ = word(headerDict.lookup("class"));
00074
00075 word headerObject(headerDict.lookup("object"));
00076 if (IOobject::debug && headerObject != name())
00077 {
00078 IOWarningIn("IOobject::readHeader(Istream&)", is)
00079 << " object renamed from "
00080 << name() << " to " << headerObject
00081 << " for file " << is.name() << endl;
00082 }
00083
00084
00085 headerDict.readIfPresent("note", note_);
00086 }
00087 else
00088 {
00089 SeriousIOErrorIn("IOobject::readHeader(Istream&)", is)
00090 << "First token could not be read or is not the keyword 'FoamFile'"
00091 << nl << nl << "Check header is of the form:" << nl << endl;
00092
00093 writeHeader(Info);
00094
00095 return false;
00096 }
00097
00098
00099 if (is.good())
00100 {
00101 objState_ = GOOD;
00102 }
00103 else
00104 {
00105 if (rOpt_ == MUST_READ)
00106 {
00107 FatalIOErrorIn("IOobject::readHeader(Istream&)", is)
00108 << " stream failure while reading header"
00109 << " on line " << is.lineNumber()
00110 << " of file " << is.name()
00111 << " for essential object" << name()
00112 << exit(FatalIOError);
00113 }
00114
00115 if (IOobject::debug)
00116 {
00117 Info<< "IOobject::readHeader(Istream&) :"
00118 << " stream failure while reading header"
00119 << " on line " << is.lineNumber()
00120 << " of file " << is.name() << endl;
00121 }
00122
00123 objState_ = BAD;
00124
00125 return false;
00126 }
00127
00128 if (IOobject::debug)
00129 {
00130 Info<< " .... read" << endl;
00131 }
00132
00133 return true;
00134 }
00135
00136
00137