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