ofstreamPointer Class Reference

A wrapped std::ofstream with possible compression handling (ogzstream) that behaves much like a std::unique_ptr. More...

Inheritance diagram for ofstreamPointer:
[legend]

Public Member Functions

 ofstreamPointer () noexcept=default
 Default construct (empty) More...
 
 ofstreamPointer (const ofstreamPointer &)=delete
 No copy construct. More...
 
 ofstreamPointer (ofstreamPointer &&)=default
 Move construct. More...
 
void operator= (const ofstreamPointer &)=delete
 No copy assignment. More...
 
ofstreamPointeroperator= (ofstreamPointer &&)=default
 Move assignment. More...
 
 ~ofstreamPointer ()=default
 Destructor. More...
 
 ofstreamPointer (std::nullptr_t)
 Construct as null output stream using Foam::ocountstream. More...
 
 ofstreamPointer (const fileName &pathname, const bool append)
 Construct from pathname, with specified append option. More...
 
 ofstreamPointer (const fileName &pathname, IOstreamOption::compressionType comp=IOstreamOption::UNCOMPRESSED, const bool append=false)
 
std::ostream * get () noexcept
 The stream pointer (ofstream or ogzstream) More...
 
const std::ostream * get () const noexcept
 The stream pointer (ofstream or ogzstream) More...
 
IOstreamOption::compressionType whichCompression () const
 Which compression type? More...
 
std::ostream * release () noexcept
 Return managed pointer and release ownership. More...
 
void reset (std::ostream *ptr) noexcept
 Replace the managed pointer. More...
 
std::ostream & operator* ()
 Reference to the stream (no nullptr checking) More...
 
const std::ostream & operator* () const
 Const-reference to the stream (no nullptr checking) More...
 
std::ostream * operator-> () noexcept
 Pointer dereference. More...
 
const std::ostream * operator-> () const noexcept
 Pointer dereference. More...
 

Static Public Member Functions

static bool supports_gz ()
 True if compiled with libz support. More...
 

Protected Member Functions

void reopen_gz (const std::string &pathname_gz)
 Special 'rewind' method for compressed stream. More...
 
void reopen (const std::string &pathname)
 General 'rewind' method (non-compressed) More...
 

Detailed Description

A wrapped std::ofstream with possible compression handling (ogzstream) that behaves much like a std::unique_ptr.

Note
No operator bool to avoid inheritance ambiguity with std::ios::operator bool.
Source files

Definition at line 161 of file fstreamPointer.H.

Constructor & Destructor Documentation

◆ ofstreamPointer() [1/6]

ofstreamPointer ( )
defaultnoexcept

Default construct (empty)

◆ ofstreamPointer() [2/6]

ofstreamPointer ( const ofstreamPointer )
delete

No copy construct.

◆ ofstreamPointer() [3/6]

ofstreamPointer ( ofstreamPointer &&  )
default

Move construct.

◆ ~ofstreamPointer()

~ofstreamPointer ( )
default

Destructor.

◆ ofstreamPointer() [4/6]

ofstreamPointer ( std::nullptr_t  )
explicit

Construct as null output stream using Foam::ocountstream.

Definition at line 135 of file fstreamPointers.C.

◆ ofstreamPointer() [5/6]

ofstreamPointer ( const fileName pathname,
const bool  append 
)
inline

Construct from pathname, with specified append option.

Definition at line 207 of file fstreamPointer.H.

◆ ofstreamPointer() [6/6]

ofstreamPointer ( const fileName pathname,
IOstreamOption::compressionType  comp = IOstreamOption::UNCOMPRESSED,
const bool  append = false 
)
explicit

Construct from pathname, with preferred compression and specified append option

Definition at line 141 of file fstreamPointers.C.

References append(), IOstreamOption::COMPRESSED, Foam::endl(), Foam::mode(), Foam::nl, Foam::removeConflictingFiles(), IOstreamOption::UNCOMPRESSED, and Foam::Warning.

Here is the call graph for this function:

Member Function Documentation

◆ reopen_gz()

void reopen_gz ( const std::string &  pathname_gz)
protected

Special 'rewind' method for compressed stream.

Definition at line 210 of file fstreamPointers.C.

Referenced by OFstream::rewind().

Here is the caller graph for this function:

◆ reopen()

void reopen ( const std::string &  pathname)
protected

General 'rewind' method (non-compressed)

Definition at line 226 of file fstreamPointers.C.

Referenced by OFstream::rewind().

Here is the caller graph for this function:

◆ operator=() [1/2]

void operator= ( const ofstreamPointer )
delete

No copy assignment.

◆ operator=() [2/2]

ofstreamPointer & operator= ( ofstreamPointer &&  )
default

Move assignment.

◆ supports_gz()

bool supports_gz ( )
static

True if compiled with libz support.

Definition at line 83 of file fstreamPointers.C.

Referenced by Time::readDict().

Here is the caller graph for this function:

◆ get() [1/2]

std::ostream * get ( )
inlinenoexcept

The stream pointer (ofstream or ogzstream)

Definition at line 231 of file fstreamPointer.H.

Referenced by OFstream::OFstream(), OFstream::rewind(), and OFstream::stdStream().

Here is the caller graph for this function:

◆ get() [2/2]

const std::ostream * get ( ) const
inlinenoexcept

The stream pointer (ofstream or ogzstream)

Definition at line 234 of file fstreamPointer.H.

◆ whichCompression()

Foam::IOstreamOption::compressionType whichCompression ( ) const

Which compression type?

Definition at line 257 of file fstreamPointers.C.

References IOstreamOption::COMPRESSED, and IOstreamOption::UNCOMPRESSED.

Referenced by OFstream::rewind().

Here is the caller graph for this function:

◆ release()

std::ostream * release ( )
inlinenoexcept

Return managed pointer and release ownership.

Definition at line 243 of file fstreamPointer.H.

◆ reset()

void reset ( std::ostream *  ptr)
inlinenoexcept

Replace the managed pointer.

Definition at line 246 of file fstreamPointer.H.

◆ operator*() [1/2]

std::ostream & operator* ( )
inline

Reference to the stream (no nullptr checking)

Definition at line 252 of file fstreamPointer.H.

◆ operator*() [2/2]

const std::ostream & operator* ( ) const
inline

Const-reference to the stream (no nullptr checking)

Definition at line 255 of file fstreamPointer.H.

◆ operator->() [1/2]

std::ostream * operator-> ( )
inlinenoexcept

Pointer dereference.

Definition at line 258 of file fstreamPointer.H.

◆ operator->() [2/2]

const std::ostream * operator-> ( ) const
inlinenoexcept

Pointer dereference.

Definition at line 261 of file fstreamPointer.H.


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