53 headerClassName_ = headerDict.
get<
word>(
"class");
55 const word headerObject(headerDict.
get<
word>(
"object"));
65 if (val) sizeofLabel_ =
static_cast<unsigned char>(val);
68 if (val) sizeofScalar_ =
static_cast<unsigned char>(val);
88 <<
" stream not open for reading essential object from file " 96 <<
" stream not open for reading from file " 97 << is.relativeName() <<
endl;
103 token firstToken(is);
105 if (is.good() && firstToken.isWord(
"FoamFile"))
107 headerDict.read(is,
false);
109 IOstreamOption streamOpt = parseHeader(headerDict);
111 is.format(streamOpt.format());
112 is.version(streamOpt.version());
113 is.setLabelByteSize(sizeofLabel_);
114 is.setScalarByteSize(sizeofScalar_);
119 <<
"First token could not be read or is not 'FoamFile'" 121 <<
"Check header is of the form:" <<
nl <<
endl;
126 headerClassName_.clear();
132 objState_ = (is.good() ? objectState::GOOD : objectState::BAD);
136 Info<<
" .... read - state: " 137 << (objState_ == objectState::GOOD ?
"good" :
"bad")
142 if (objState_ == objectState::BAD)
144 if (isReadRequired())
147 <<
" stream failure while reading header" 148 <<
" on line " << is.lineNumber()
149 <<
" of file " << is.relativeName()
150 <<
" for essential object:" <<
name()
157 <<
"Stream failure while reading header" 158 <<
" on line " << is.lineNumber()
159 <<
" of file " << is.relativeName() <<
endl;
178 bool Foam::IOobject::readAndCheckHeader
181 const word& typeName,
182 const bool checkType,
188 headerClassName_.clear();
191 const bool masterOnly
213 handler.filePath(isGlobal, *
this, typeName,
search)
215 ok = handler.readHeader(*
this, fName, typeName);
221 && !typeName.empty() && headerClassName_ != typeName
228 <<
"Unexpected class name \"" << headerClassName_
229 <<
"\" expected \"" << typeName
230 <<
"\" when reading " << fName <<
endl;
250 handler.filePath(isGlobal, *
this, typeName,
search)
252 ok = handler.readHeader(*
this, fName, typeName);
257 && !typeName.empty() && headerClassName_ != typeName
264 <<
"Unexpected class name \"" << headerClassName_
265 <<
"\" expected \"" << typeName
266 <<
"\" when reading " << fName <<
endl;
#define SeriousIOErrorInFunction(ios)
Report an IO error message using Foam::SeriousError.
static void writeHeader(Ostream &os, const word &fieldName)
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
constexpr char nl
The newline '\n' character (0x0a)
A token holds an item read from Istream.
Ostream & endl(Ostream &os)
Add newline and flush stream.
static bool & parRun() noexcept
Test if this a parallel run.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler()
A simple container for options an IOstream can normally have.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
IOstreamOption parseHeader(const dictionary &headerDict)
Parse 'FoamFile' header contents and set the IOobject characteristics and return the stream character...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
A class for handling words, derived from Foam::string.
int debug
Static debugging option.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
static fileCheckTypes fileModificationChecking
Type of file modification checking.
static void broadcasts(const label comm, Type &arg1, Args &&... args)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel. ...
unsigned scalarByteSize(const std::string &str)
Extract scalar size (in bytes) from "scalar=" tag in string.
#define WarningInFunction
Report a warning using Foam::Warning.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
versionNumber version() const noexcept
Get the stream version.
unsigned labelByteSize(const std::string &str)
Extract label size (in bytes) from "label=" tag in string.
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
bool readHeader(Istream &is)
Read header ('FoamFile' dictionary) and set the IOobject and stream characteristics.
streamFormat format() const noexcept
Get the current stream format.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
#define InfoInFunction
Report an information message using Foam::Info.