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);
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;
178bool Foam::IOobject::readAndCheckHeader
182 const bool checkType,
188 headerClassName_.clear();
191 const bool masterOnly
212 ok = handler.readHeader(*
this, fName,
typeName);
215 if (ok && checkType && !isHeaderClass(
typeName))
221 <<
"Unexpected class name \"" << headerClassName()
223 <<
"\" when reading " << fName <<
endl;
245 ok = handler.readHeader(*
this, fName,
typeName);
247 if (ok && checkType && !isHeaderClass(
typeName))
253 <<
"Unexpected class name \"" << headerClassName()
255 <<
"\" when reading " << fName <<
endl;
static bool isReadRequired(readOption opt) noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
bool readHeader(Istream &is)
Read header ('FoamFile' dictionary) and set the IOobject and stream characteristics.
static bool fileModificationChecking_masterOnly() noexcept
Test fileModificationChecking for master-only.
IOstreamOption parseHeader(const dictionary &headerDict)
Parse 'FoamFile' header contents and set the IOobject characteristics and return the stream character...
A simple container for options an IOstream can normally have.
versionNumber version() const noexcept
Get the stream version.
streamFormat format() const noexcept
Get the current stream format.
label lineNumber() const noexcept
Const access to the current stream line number.
bool good() const noexcept
True if next operation might succeed.
virtual const fileName & name() const
The name of the stream.
void setLabelByteSize(unsigned nbytes) noexcept
Set the sizeof (label) in bytes associated with the stream.
void setScalarByteSize(unsigned nbytes) noexcept
Set the sizeof (scalar) in bytes associated with the stream.
fileName relativeName() const
Return the name of the stream relative to the current case.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
static void broadcasts(const int communicator, Type &value, Args &&... values)
Broadcast multiple items to all communicator ranks. Does nothing in non-parallel.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
static label worldComm
Communicator for all ranks. May differ from commGlobal() if local worlds are in use.
static bool & parRun() noexcept
Test if this a parallel run.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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.
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...
bool read(Istream &is)
Read dictionary from Istream (discards the header). Reads entries until EOF or when the first token i...
A class for handling file names.
A token holds an item read from Istream.
bool isWord() const noexcept
Token is word-variant (WORD, DIRECTIVE).
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
#define SeriousIOErrorInFunction(ios)
Report an IO error message using Foam::SeriousError.
#define WarningInFunction
Report a warning using Foam::Warning.
#define InfoInFunction
Report an information message using Foam::Info.
unsigned scalarByteSize(const std::string &str)
Extract scalar size (in bytes) from "scalar=" tag in string.
unsigned labelByteSize(const std::string &str)
Extract label size (in bytes) from "label=" tag in string.
refPtr< fileOperation > fileHandler(std::nullptr_t)
Delete current file handler - forwards to fileOperation::handler().
static void writeHeader(Ostream &os, const word &fieldName)
messageStream Info
Information stream (stdout output on master, null elsewhere).
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
errorManipArg< error, int > exit(error &err, const int errNo=1)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
constexpr char nl
The newline '\n' character (0x0a).