45#ifndef Foam_IOstream_H
46#define Foam_IOstream_H
68#define Foam_IOstream_extras
142 void setState(std::ios_base::iostate state)
noexcept
150 ioState_ = std::ios_base::iostate(0);
172 ioState_(std::ios_base::iostate(0)),
174 sizeofLabel_(static_cast<unsigned char>(sizeof(label))),
215 virtual bool check(
const char* operation)
const;
242 return ioState_ & std::ios_base::eofbit;
248 return ioState_ & (std::ios_base::badbit | std::ios_base::failbit);
254 return ioState_ & std::ios_base::badbit;
299 template<
class T = label>
300 typename std::enable_if<std::is_integral<T>::value,
bool>
::type
308 template<
class T = scalar>
309 typename std::enable_if<std::is_floating_point<T>::value,
bool>
::type
340 virtual ios_base::fmtflags
flags()
const = 0;
376 virtual ios_base::fmtflags
flags(
const ios_base::fmtflags
f) = 0;
379 ios_base::fmtflags
setf(
const ios_base::fmtflags
f)
385 ios_base::fmtflags
setf
387 const ios_base::fmtflags
f,
388 const ios_base::fmtflags mask
395 void unsetf(
const ios_base::fmtflags
f)
424Ostream&
operator<<(Ostream&
os,
const InfoProxy<IOstream>& ip);
443 io.setf(ios_base::dec, ios_base::dec|ios_base::hex|ios_base::oct);
449 io.setf(ios_base::hex, ios_base::dec|ios_base::hex|ios_base::oct);
455 io.setf(ios_base::oct, ios_base::dec|ios_base::hex|ios_base::oct);
461 io.setf(ios_base::fixed, ios_base::floatfield);
467 io.setf(ios_base::scientific, ios_base::floatfield);
478template<
class IS>
inline void inputLoop(IS&) {}
481template<
class OS>
inline void outputLoop(OS&) {}
484template<
class IS,
class Type,
class... Args>
492template<
class OS,
class Type,
class... Args>
A character and a pointer to a character string.
Representation of a major/minor version number.
The IOstreamOption is a simple container for options an IOstream can normally have.
streamFormat
Data format (ascii | binary)
compressionType
Compression treatment (UNCOMPRESSED | COMPRESSED)
@ UNCOMPRESSED
compression = false
An IOstream is an abstract base class for all input/output systems; be they streams,...
bool fail() const noexcept
True if next operation will fail.
std::enable_if< std::is_integral< T >::value, bool >::type checkLabelSize() const noexcept
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())
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.
void unsetf(const ios_base::fmtflags f)
Unset flags of stream.
void setBad()
Set stream state to be 'bad'.
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
Return the name of the stream.
ios_base::fmtflags setf(const ios_base::fmtflags f)
Set flags of stream.
ios_base::fmtflags setf(const ios_base::fmtflags f, const ios_base::fmtflags mask)
Set flags of given field of stream.
void setEof() noexcept
Set stream state as reached 'eof'.
InfoProxy< IOstream > info() const
Return info proxy.
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.
streamAccess openClosed_
The stream open/closed state.
IOstream(IOstreamOption::streamFormat fmt, IOstreamOption::versionNumber ver, IOstreamOption::compressionType cmp=IOstreamOption::UNCOMPRESSED)
Construct with format, version (compression)
bool operator!() const noexcept
Return 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.
virtual ios_base::fmtflags flags() const =0
Return flags of stream.
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'.
std::enable_if< std::is_floating_point< T >::value, bool >::type checkScalarSize() const noexcept
virtual ios_base::fmtflags flags(const ios_base::fmtflags f)=0
Set flags of stream.
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.
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)
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
void inputLoop(IS &)
Termination for input looping (no-op)
void outputLoop(OS &)
Termination for output looping (no-op)
IOstream & fixed(IOstream &io)
IOstream & oct(IOstream &io)
IOstream & scientific(IOstream &io)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
IOstream &(* IOstreamManip)(IOstream &)
An IOstream manipulator.
IOstream & dec(IOstream &io)
Foam::argList args(argc, argv)