Public Member Functions | List of all members
OSstream Class Reference

Generic output stream. More...

Inheritance diagram for OSstream:
Inheritance graph
[legend]
Collaboration diagram for OSstream:
Collaboration graph
[legend]

Public Member Functions

 OSstream (ostream &os, const string &name, streamFormat format=ASCII, versionNumber version=currentVersion, compressionType compression=UNCOMPRESSED)
 Set stream status. More...
 
virtual const fileNamename () const
 Return the name of the stream. More...
 
virtual fileNamename ()
 Return non-const access to the name of the stream. More...
 
virtual ios_base::fmtflags flags () const
 Return flags of output stream. More...
 
virtual Ostreamwrite (const token &)
 Write next token to stream. More...
 
virtual Ostreamwrite (const char)
 Write character. More...
 
virtual Ostreamwrite (const char *)
 Write character string. More...
 
virtual Ostreamwrite (const word &)
 Write word. More...
 
virtual Ostreamwrite (const string &)
 Write string. More...
 
virtual OstreamwriteQuoted (const std::string &, const bool quoted=true)
 Write std::string surrounded by quotes. More...
 
virtual Ostreamwrite (const int32_t)
 Write int32_t. More...
 
virtual Ostreamwrite (const int64_t)
 Write int64_t. More...
 
virtual Ostreamwrite (const floatScalar)
 Write floatScalar. More...
 
virtual Ostreamwrite (const doubleScalar)
 Write doubleScalar. More...
 
virtual Ostreamwrite (const char *, std::streamsize)
 Write binary block. More...
 
virtual void indent ()
 Add indentation characters. More...
 
virtual ios_base::fmtflags flags (const ios_base::fmtflags flags)
 Set flags of output stream. More...
 
virtual void flush ()
 Flush stream. More...
 
virtual void endl ()
 Add newline and flush stream. More...
 
virtual int width () const
 Get width of output field. More...
 
virtual int width (const int)
 Set width of output field (and return old width) More...
 
virtual int precision () const
 Get precision of output field. More...
 
virtual int precision (const int)
 Set precision of output field (and return old precision) More...
 
virtual ostream & stdStream ()
 Access to underlying std::ostream. More...
 
virtual const ostream & stdStream () const
 Const access to underlying std::ostream. More...
 
virtual void print (Ostream &) const
 Print description of IOstream to Ostream. More...
 
- Public Member Functions inherited from Ostream
 Ostream (streamFormat format=ASCII, versionNumber version=currentVersion, compressionType compression=UNCOMPRESSED)
 Set stream status. More...
 
virtual ~Ostream ()
 Destructor. More...
 
virtual Ostreamwrite (const keyType &)
 Write keyType. More...
 
unsigned short indentLevel () const
 Return indent level. More...
 
unsigned short & indentLevel ()
 Access to indent level. More...
 
void incrIndent ()
 Incrememt the indent level. More...
 
void decrIndent ()
 Decrememt the indent level. More...
 
OstreamwriteKeyword (const keyType &)
 Write the keyword followed by an appropriate indentation. More...
 
Ostreamoperator() () const
 Return a non-const reference to const Ostream. More...
 
- Public Member Functions inherited from IOstream
 IOstream (streamFormat format, versionNumber version, compressionType compression=UNCOMPRESSED)
 Construct setting format and version. More...
 
virtual ~IOstream ()
 Destructor. More...
 
virtual bool check (const char *operation) const
 Check IOstream status for given operation. More...
 
void fatalCheck (const char *operation) const
 Check IOstream status for given operation. More...
 
bool opened () const
 Return true if stream has been opened. More...
 
bool closed () const
 Return true if stream is closed. More...
 
bool good () const
 Return true if next operation might succeed. More...
 
bool eof () const
 Return true if end of input seen. More...
 
bool fail () const
 Return true if next operation will fail. More...
 
bool bad () const
 Return true if stream is corrupted. More...
 
 operator void * () const
 Return non-zero if the stream has not failed. More...
 
bool operator! () const
 Return true if the stream has failed. More...
 
streamFormat format () const
 Return current stream format. More...
 
streamFormat format (const streamFormat fmt)
 Set the stream format. More...
 
streamFormat format (const word &fmt)
 Set the stream format from word. More...
 
versionNumber version () const
 Return the stream version. More...
 
versionNumber version (const versionNumber ver)
 Set the stream version. More...
 
compressionType compression () const
 Return the stream compression. More...
 
compressionType compression (const compressionType cmp)
 Set the stream compression. More...
 
compressionType compression (const word &cmp)
 Set the stream compression from word. More...
 
label lineNumber () const
 Return current stream line number. More...
 
labellineNumber ()
 Return current stream line number. More...
 
label lineNumber (const label ln)
 Set the stream line number. More...
 
void setEof ()
 Set stream to have reached eof. More...
 
void setFail ()
 Set stream to have failed. More...
 
void setBad ()
 Set stream to be bad. More...
 
ios_base::fmtflags setf (const ios_base::fmtflags f)
 Set flags of stream. More...
 
ios_base::fmtflags setf (const ios_base::fmtflags f, const ios_base::fmtflags mask)
 Set flags of given field of stream. More...
 
void unsetf (const ios_base::fmtflags uf)
 Unset flags of stream. More...
 
void print (Ostream &, const int streamState) const
 Check given stream state bits. More...
 
InfoProxy< IOstreaminfo () const
 Return info proxy. More...
 

Additional Inherited Members

- Public Types inherited from IOstream
enum  streamAccess { OPENED, CLOSED }
 Enumeration for whether the stream open or closed. More...
 
enum  streamFormat { ASCII, BINARY }
 Enumeration for the format of data in the stream. More...
 
enum  compressionType { UNCOMPRESSED, COMPRESSED }
 Enumeration for the format of data in the stream. More...
 
- Static Public Member Functions inherited from IOstream
static streamFormat formatEnum (const word &)
 Return stream format of given format name. More...
 
static compressionType compressionEnum (const word &)
 Return compression of given compression name. More...
 
static unsigned int defaultPrecision ()
 Return the default precision. More...
 
static unsigned int defaultPrecision (unsigned int p)
 Reset the default precision (and return old precision) More...
 
- Static Public Attributes inherited from IOstream
static const versionNumber originalVersion
 Original version number. More...
 
static const versionNumber currentVersion
 Current version number. More...
 
static unsigned int precision_
 Default precision. More...
 
- Protected Member Functions inherited from IOstream
void setOpened ()
 Set stream opened. More...
 
void setClosed ()
 Set stream closed. More...
 
void setState (ios_base::iostate state)
 Set stream state. More...
 
void setGood ()
 Set stream to be good. More...
 
- Protected Attributes inherited from Ostream
unsigned short indentLevel_
 Current indent level. More...
 
- Protected Attributes inherited from IOstream
label lineNumber_
 
- Static Protected Attributes inherited from Ostream
static const unsigned short indentSize_ = 4
 Number of spaces per indent level. More...
 
static const unsigned short entryIndentation_ = 16
 Indentation of the entry from the start of the keyword. More...
 

Detailed Description

Generic output stream.

Source files

Definition at line 51 of file OSstream.H.

Constructor & Destructor Documentation

◆ OSstream()

OSstream ( ostream &  os,
const string name,
streamFormat  format = ASCII,
versionNumber  version = currentVersion,
compressionType  compression = UNCOMPRESSED 
)
inline

Set stream status.

Definition at line 31 of file OSstreamI.H.

Member Function Documentation

◆ name() [1/2]

virtual const fileName& name ( ) const
inlinevirtual

◆ name() [2/2]

virtual fileName& name ( )
inlinevirtual

Return non-const access to the name of the stream.

Useful to alter the stream name

Reimplemented from IOstream.

Reimplemented in OFstream.

Definition at line 95 of file OSstream.H.

◆ flags() [1/2]

std::ios_base::fmtflags flags ( ) const
virtual

Return flags of output stream.

Implements IOstream.

Definition at line 259 of file OSstream.C.

◆ write() [1/10]

Foam::Ostream & write ( const token t)
virtual

Write next token to stream.

Implements Ostream.

Reimplemented in prefixOSstream.

Definition at line 32 of file OSstream.C.

References token::BEGIN_BLOCK, token::END_BLOCK, token::HASH, token::stringToken(), token::type(), token::VARIABLE, token::VERBATIMSTRING, and OSstream::writeQuoted().

Referenced by searchableSurfaces::checkIntersection(), OSstream::endl(), prefixOSstream::write(), OBJstream::write(), and OBJstream::writeQuoted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [2/10]

Foam::Ostream & write ( const char  c)
virtual

Write character.

Implements Ostream.

Reimplemented in OBJstream, and prefixOSstream.

Definition at line 50 of file OSstream.C.

References Foam::constant::universal::c, IOstream::lineNumber_, token::NL, and IOstream::setState().

Here is the call graph for this function:

◆ write() [3/10]

Foam::Ostream & write ( const char *  str)
virtual

Write character string.

Implements Ostream.

Reimplemented in ensightFile, OBJstream, and prefixOSstream.

Definition at line 62 of file OSstream.C.

References string::count(), IOstream::lineNumber_, token::NL, and IOstream::setState().

Here is the call graph for this function:

◆ write() [4/10]

Foam::Ostream & write ( const word str)
virtual

Write word.

Implements Ostream.

Reimplemented in OBJstream, and prefixOSstream.

Definition at line 71 of file OSstream.C.

References IOstream::setState().

Here is the call graph for this function:

◆ write() [5/10]

Foam::Ostream & write ( const string str)
virtual

Write string.

In the rare case that the string contains a final trailing backslash, it will be dropped to the appearance of an escaped double-quote.

Implements Ostream.

Reimplemented in ensightFile, OBJstream, and prefixOSstream.

Definition at line 79 of file OSstream.C.

References token::BEGIN_STRING, Foam::constant::universal::c, token::END_STRING, IOstream::lineNumber_, token::NL, IOstream::setState(), and OSstream::writeQuoted().

Here is the call graph for this function:

◆ writeQuoted()

Foam::Ostream & writeQuoted ( const std::string &  str,
const bool  quoted = true 
)
virtual

Write std::string surrounded by quotes.

Optional write without quotes.

Implements Ostream.

Reimplemented in OBJstream, and prefixOSstream.

Definition at line 125 of file OSstream.C.

References token::BEGIN_STRING, Foam::constant::universal::c, string::count(), token::END_STRING, IOstream::lineNumber_, token::NL, and IOstream::setState().

Referenced by dynamicCode::copyAndFilter(), OSstream::write(), and prefixOSstream::writeQuoted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write() [6/10]

Foam::Ostream & write ( const int32_t  val)
virtual

Write int32_t.

Implements Ostream.

Reimplemented in prefixOSstream.

Definition at line 186 of file OSstream.C.

References IOstream::setState().

Here is the call graph for this function:

◆ write() [7/10]

Foam::Ostream & write ( const int64_t  val)
virtual

Write int64_t.

Implements Ostream.

Reimplemented in prefixOSstream.

Definition at line 194 of file OSstream.C.

References IOstream::setState().

Here is the call graph for this function:

◆ write() [8/10]

Foam::Ostream & write ( const floatScalar  val)
virtual

Write floatScalar.

Implements Ostream.

Reimplemented in prefixOSstream.

Definition at line 202 of file OSstream.C.

References IOstream::setState().

Here is the call graph for this function:

◆ write() [9/10]

Foam::Ostream & write ( const doubleScalar  val)
virtual

Write doubleScalar.

Implements Ostream.

Reimplemented in prefixOSstream.

Definition at line 210 of file OSstream.C.

References IOstream::setState().

Here is the call graph for this function:

◆ write() [10/10]

Foam::Ostream & write ( const char *  buf,
std::streamsize  count 
)
virtual

Write binary block.

Implements Ostream.

Reimplemented in prefixOSstream, and ensightFile.

Definition at line 218 of file OSstream.C.

References Foam::abort(), token::BEGIN_LIST, IOstream::BINARY, token::END_LIST, Foam::FatalIOError, FatalIOErrorInFunction, IOstream::format(), and IOstream::setState().

Here is the call graph for this function:

◆ indent()

void indent ( )
virtual

Add indentation characters.

Implements Ostream.

Reimplemented in prefixOSstream.

Definition at line 237 of file OSstream.C.

References Ostream::indentLevel_, and Ostream::indentSize_.

Referenced by prefixOSstream::indent().

Here is the caller graph for this function:

◆ flags() [2/2]

std::ios_base::fmtflags flags ( const ios_base::fmtflags  flags)
virtual

Set flags of output stream.

Implements IOstream.

Definition at line 265 of file OSstream.C.

◆ flush()

void flush ( )
virtual

◆ endl()

void endl ( )
virtual

Add newline and flush stream.

Implements Ostream.

Definition at line 252 of file OSstream.C.

References OSstream::write().

Here is the call graph for this function:

◆ width() [1/2]

int width ( ) const
virtual

Get width of output field.

Implements Ostream.

Definition at line 273 of file OSstream.C.

◆ width() [2/2]

int width ( const int  w)
virtual

Set width of output field (and return old width)

Implements Ostream.

Definition at line 279 of file OSstream.C.

◆ precision() [1/2]

int precision ( ) const
virtual

◆ precision() [2/2]

int precision ( const int  p)
virtual

Set precision of output field (and return old precision)

Implements Ostream.

Definition at line 291 of file OSstream.C.

◆ stdStream() [1/2]

virtual ostream& stdStream ( )
inlinevirtual

Access to underlying std::ostream.

Reimplemented in OFstream.

Definition at line 178 of file OSstream.H.

Referenced by OStringStream::rewind(), OStringStream::str(), decomposedBlockData::writeBlocks(), and OStringStream::~OStringStream().

Here is the caller graph for this function:

◆ stdStream() [2/2]

virtual const ostream& stdStream ( ) const
inlinevirtual

Const access to underlying std::ostream.

Reimplemented in OFstream.

Definition at line 184 of file OSstream.H.

References OSstream::print().

Here is the call graph for this function:

◆ print()

void print ( Ostream os) const
virtual

Print description of IOstream to Ostream.

Reimplemented from IOstream.

Reimplemented in prefixOSstream, OFstream, and OStringStream.

Definition at line 43 of file SstreamsPrint.C.

References ISstream::name(), and IOstream::print().

Referenced by OStringStream::print(), OFstream::print(), prefixOSstream::print(), and OSstream::stdStream().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: