51 headerClassName_ = headerDict.
get<
word>(
"class");
53 const word headerObject(headerDict.
get<
word>(
"object"));
63 if (val) sizeofLabel_ =
static_cast<unsigned char>(val);
66 if (val) sizeofScalar_ =
static_cast<unsigned char>(val);
86 <<
" stream not open for reading essential object from file " 94 <<
" stream not open for reading from file " 95 << is.relativeName() <<
endl;
101 token firstToken(is);
103 if (is.good() && firstToken.isWord(
"FoamFile"))
105 headerDict.read(is,
false);
107 IOstreamOption streamOpt = parseHeader(headerDict);
109 is.format(streamOpt.format());
110 is.version(streamOpt.version());
111 is.setLabelByteSize(sizeofLabel_);
112 is.setScalarByteSize(sizeofScalar_);
117 <<
"First token could not be read or is not 'FoamFile'" 119 <<
"Check header is of the form:" <<
nl <<
endl;
124 headerClassName_.clear();
130 objState_ = (is.good() ? objectState::GOOD : objectState::BAD);
134 Info<<
" .... read - state: " 135 << (objState_ == objectState::GOOD ?
"good" :
"bad")
140 if (objState_ == objectState::BAD)
142 if (isReadRequired())
145 <<
" stream failure while reading header" 146 <<
" on line " << is.lineNumber()
147 <<
" of file " << is.relativeName()
148 <<
" for essential object:" <<
name()
155 <<
"Stream failure while reading header" 156 <<
" on line " << is.lineNumber()
157 <<
" of file " << is.relativeName() <<
endl;
169 dictionary headerDict;
#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.
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.
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 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...
unsigned scalarByteSize(const std::string &str)
Extract scalar size (in bytes) from "scalar=" tag in string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
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)
#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.