45#ifndef Foam_IOstream_H
46#define Foam_IOstream_H
68#define Foam_IOstream_extras
80Ostream&
operator<<(Ostream&,
const InfoProxy<IOstream>&);
149 void setState(std::ios_base::iostate state)
noexcept
181 sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
218 virtual bool check(
const char* operation)
const;
245 return ioState_ & std::ios_base::eofbit;
251 return ioState_ & (std::ios_base::badbit | std::ios_base::failbit);
257 return ioState_ & std::ios_base::badbit;
261 explicit operator bool() const
noexcept
302 template<
class T,
class = std::enable_if_t<std::is_
integral_v<T>>>
310 template<
class T,
class = std::enable_if_t<std::is_
floating_po
int_v<T>>>
373 static unsigned int minPrecision(
unsigned int prec)
noexcept
402 virtual std::ios_base::fmtflags
flags()
const = 0;
405 virtual std::ios_base::fmtflags
flags(std::ios_base::fmtflags) = 0;
408 std::ios_base::fmtflags
setf(std::ios_base::fmtflags
f)
414 std::ios_base::fmtflags
setf
416 const std::ios_base::fmtflags
f,
417 const std::ios_base::fmtflags mask
424 std::ios_base::fmtflags
unsetf(std::ios_base::fmtflags
f)
463 io.setf(std::ios_base::dec, std::ios_base::basefield);
469 io.setf(std::ios_base::hex, std::ios_base::basefield);
475 io.setf(std::ios_base::oct, std::ios_base::basefield);
481 io.setf(std::ios_base::fixed, std::ios_base::floatfield);
487 io.setf(std::ios_base::scientific, std::ios_base::floatfield);
504template<
class StreamType>
533template<
class IS,
class Type,
class... Args>
537 if constexpr (
sizeof...(args))
544template<
class OS,
class Type,
class... Args>
548 if constexpr (
sizeof...(args))
A character and a pointer to a character string.
StreamAllocator()=default
Default construct (empty).
Foam::osha1stream stream_
Representation of a major/minor version number.
constexpr IOstreamOption(streamFormat fmt=streamFormat::ASCII, compressionType comp=compressionType::UNCOMPRESSED) noexcept
Default construct (ASCII, UNCOMPRESSED, currentVersion) or construct with format, compression.
streamFormat
Data format (ascii | binary | coherent).
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED).
@ UNCOMPRESSED
compression = false
An IOstream is an abstract base class for all input/output systems; be they streams,...
std::ios_base::fmtflags setf(std::ios_base::fmtflags f)
Set stream flag(s), return old stream flags.
bool fail() const noexcept
True if next operation will fail.
void setBad() noexcept
Set stream state to be 'bad'.
label lineNumber() const noexcept
Const access to the current stream line number.
virtual ~IOstream()=default
Destructor.
bool fatalCheck(const char *operation) const
Check IOstream status for given operation.
virtual bool check(const char *operation) const
Check IOstream status for given operation.
unsigned scalarByteSize() const noexcept
The sizeof (scalar) in bytes associated with the stream.
static unsigned int precision_
Default precision.
IOstream(IOstreamOption streamOpt=IOstreamOption())
Default construct (ASCII, uncompressed), construct with specified stream option.
label & lineNumber() noexcept
Non-const access to the current stream line number.
unsigned char sizeofScalar_
The sizeof (scalar), possibly read from the header.
bool good() const noexcept
True if next operation might succeed.
bool bad() const noexcept
True if stream is corrupted.
bool opened() const noexcept
True if stream has been opened.
IOstream(const IOstream &)=default
Copy construct.
virtual void print(Ostream &os) const
Print stream description to Ostream.
label lineNumber_
The file line.
virtual const fileName & name() const
The name of the stream.
bool checkScalarSize() const noexcept
Test if the scalar byte-size associated with the stream is the same as the given type.
InfoProxy< IOstream > info() const noexcept
Return info proxy, used to print IOstream information to a stream.
virtual std::ios_base::fmtflags flags(std::ios_base::fmtflags)=0
Set stream flags, return old stream flags.
std::ios_base::fmtflags setf(const std::ios_base::fmtflags f, const std::ios_base::fmtflags mask)
Set stream flag(s) with mask, return old stream flags.
void setEof() noexcept
Set stream state as reached 'eof'.
virtual std::ios_base::fmtflags flags() const =0
Return current stream flags.
static unsigned int minPrecision(unsigned int prec) noexcept
Set the minimum default precision.
std::ios_base::fmtflags unsetf(std::ios_base::fmtflags f)
Unset stream flags, return old stream flags.
void setClosed() noexcept
Set stream closed.
void setLabelByteSize(unsigned nbytes) noexcept
Set the sizeof (label) in bytes associated with the stream.
bool eof() const noexcept
True if end of input seen.
bool checkNativeSizes() const noexcept
Test if the label/scalar byte-size associated with the stream are the native label/scalar sizes.
label lineNumber(const label num) noexcept
Set the stream line number.
streamAccess openClosed_
The stream open/closed state.
IOstream(IOstreamOption::streamFormat fmt, IOstreamOption::versionNumber ver, IOstreamOption::compressionType cmp=IOstreamOption::UNCOMPRESSED)
Construct with format, version (compression).
static unsigned int defaultPrecision(unsigned int prec) noexcept
Reset the default precision.
bool operator!() const noexcept
True if the stream has failed.
streamAccess
Enumeration for stream open/closed state.
@ OPENED
The stream is open.
@ CLOSED
The stream is not open.
void setScalarByteSize(unsigned nbytes) noexcept
Set the sizeof (scalar) in bytes associated with the stream.
void setState(std::ios_base::iostate state) noexcept
Set stream state.
bool fatalCheckNativeSizes(const char *operation) const
Assert that the label/scalar byte-size associated with the stream are the native label/scalar sizes.
unsigned char sizeofLabel_
The sizeof (label), possibly read from the header.
static fileName staticName_
Name for any generic stream - normally treat as readonly.
bool closed() const noexcept
True if stream is closed.
unsigned labelByteSize() const noexcept
The sizeof (label) in bytes associated with the stream.
fileName relativeName() const
Return the name of the stream relative to the current case.
void setGood() noexcept
Set stream state to be good.
void setFail() noexcept
Set stream state as 'failed'.
void setOpened() noexcept
Set stream opened.
std::ios_base::iostate ioState_
Mirror of internal stream io state.
static unsigned int defaultPrecision() noexcept
Return the default precision.
bool checkLabelSize() const noexcept
Test if the label byte-size associated with the stream is the same as the given type.
A helper class for outputting values to Ostream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A class for handling file names.
OBJstream os(runTime.globalPath()/outputName)
Implementation details for various OpenFOAM classes.
void outputLoop(OS &os, const Type &arg1, Args &&... args)
Output looping. Write first parameter and recurse.
void inputLoop(IS &is, Type &arg1, Args &&... args)
Input looping. Read into first parameter and recurse.
IOstream & fixed(IOstream &io)
IOstream & oct(IOstream &io)
IOstream & hex(IOstream &io)
IOstream & scientific(IOstream &io)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
IOstream &(* IOstreamManip)(IOstream &)
An IOstream manipulator.
IOstream & dec(IOstream &io)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Foam::argList args(argc, argv)