A wrapped std::ofstream with possible compression handling (ogzstream) that behaves much like a std::unique_ptr.
More...
#include <fstreamPointer.H>

Public Member Functions | |
| ofstreamPointer (const ofstreamPointer &)=delete | |
| No copy construct. | |
| ofstreamPointer (ofstreamPointer &&)=default | |
| Move construct. | |
| void | operator= (const ofstreamPointer &)=delete |
| No copy assignment. | |
| ofstreamPointer & | operator= (ofstreamPointer &&)=default |
| Move assignment. | |
| ~ofstreamPointer ()=default | |
| Destructor. | |
| ofstreamPointer () noexcept | |
| Default construct (empty). | |
| ofstreamPointer (std::nullptr_t) | |
| Construct as null output stream (Foam::ocountstream). | |
| ofstreamPointer (const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), IOstreamOption::appendType append=IOstreamOption::NO_APPEND, bool atomic=false) | |
| Construct from pathname, option, append, file handling atomic. | |
| ofstreamPointer (const fileName &pathname, IOstreamOption::compressionType comp, IOstreamOption::appendType append=IOstreamOption::NO_APPEND, bool atomic=false) | |
| Construct from pathname, compression, append, file handling atomic. | |
| operator bool () const noexcept | |
| True if it holds a valid pointer. | |
| std::ostream * | get () noexcept |
| The stream pointer (ofstream or ogzstream). | |
| const std::ostream * | get () const noexcept |
| The stream pointer (ofstream or ogzstream). | |
| IOstreamOption::compressionType | whichCompression () const |
| Which compression type? | |
| bool | is_appending () const noexcept |
| True if opened in append mode and file already existed. | |
| bool | is_atomic () const noexcept |
| True if file creation behaves as atomic. | |
| std::ostream * | release () noexcept |
| Return managed pointer and release ownership. | |
| void | reset (std::ostream *ptr) noexcept |
| Replace the managed pointer. | |
| std::ostream & | operator* () |
| Reference to the stream (no nullptr checking). | |
| const std::ostream & | operator* () const |
| Const-reference to the stream (no nullptr checking). | |
| std::ostream * | operator-> () noexcept |
| Pointer dereference. | |
| const std::ostream * | operator-> () const noexcept |
| Pointer dereference. | |
Static Public Member Functions | |
| static bool | supports_gz () noexcept |
| True if compiled with libz support. | |
Protected Member Functions | |
| void | reopen (const std::string &pathname) |
| Reopen for compressed/non-compressed. Discards append status. | |
| void | close (const std::string &pathname) |
| Close stream and rename file. | |
A wrapped std::ofstream with possible compression handling (ogzstream) that behaves much like a std::unique_ptr.
Definition at line 239 of file fstreamPointer.H.
|
delete |
No copy construct.
References ofstreamPointer().
Referenced by OFstream::OFstream(), OFstream::OFstream(), ofstreamPointer(), ofstreamPointer(), ofstreamPointer(), operator=(), operator=(), and ~ofstreamPointer().


|
default |
|
default |
Destructor.
References append(), Foam::noexcept, ofstreamPointer(), and supports_gz().

|
noexcept |
Default construct (empty).
Definition at line 81 of file fstreamPointers.C.
References Foam::noexcept.
|
explicit |
Construct as null output stream (Foam::ocountstream).
Definition at line 88 of file fstreamPointers.C.
|
explicit |
Construct from pathname, option, append, file handling atomic.
| pathname | The file name to open for writing |
| streamOpt | Respects (UNCOMPRESSED | COMPRESSED) |
| append | Open in specified append mode |
| atomic | Write into temporary file (not target file). This option should only be used with a stream wrapper (eg, OFstream) that handles the final renaming. |
Definition at line 95 of file fstreamPointers.C.
References append(), IOstreamOption::APPEND_APP, IOstreamOption::APPEND_ATE, IOstreamOption::COMPRESSED, IOstreamOption::compression(), Foam::endl(), fileName::FILE, filePtr, Foam::nl, IOstreamOption::NO_APPEND, Foam::rm(), fileName::SYMLINK, Foam::type(), IOstreamOption::UNCOMPRESSED, fileName::UNDEFINED, and Foam::Warning.

| ofstreamPointer | ( | const fileName & | pathname, |
| IOstreamOption::compressionType | comp, | ||
| IOstreamOption::appendType | append = IOstreamOption::NO_APPEND, | ||
| bool | atomic = false ) |
Construct from pathname, compression, append, file handling atomic.
| pathname | The file name to open for writing |
| comp | UNCOMPRESSED | COMPRESSED |
| append | Open in append mode |
| atomic | Write into temporary file (not target file). This option should only be used with a stream wrapper (eg, OFstream) that handles the final renaming. |
Definition at line 289 of file fstreamPointers.C.
References append(), and ofstreamPointer().

|
protected |
Reopen for compressed/non-compressed. Discards append status.
Definition at line 381 of file fstreamPointers.C.
Referenced by OFstream::rewind().

|
protected |
Close stream and rename file.
Definition at line 447 of file fstreamPointers.C.
Referenced by OFstream::~OFstream().

|
delete |
|
default |
|
staticnoexcept |
True if compiled with libz support.
Definition at line 46 of file fstreamPointers.C.
References Foam::noexcept.
Referenced by Time::readDict(), and ~ofstreamPointer().

|
inlineexplicitnoexcept |
True if it holds a valid pointer.
Definition at line 386 of file fstreamPointer.H.
References Foam::noexcept.
|
inlinenoexcept |
The stream pointer (ofstream or ogzstream).
Definition at line 391 of file fstreamPointer.H.
References Foam::noexcept.
Referenced by OFstream::OFstream(), OFstream::OFstream(), OFstream::rewind(), OFstream::stdStream(), and OFstream::stdStream().

|
inlinenoexcept |
The stream pointer (ofstream or ogzstream).
Definition at line 396 of file fstreamPointer.H.
References Foam::noexcept.
| Foam::IOstreamOption::compressionType whichCompression | ( | ) | const |
Which compression type?
Definition at line 510 of file fstreamPointers.C.
References IOstreamOption::COMPRESSED, and IOstreamOption::UNCOMPRESSED.
|
inlinenoexcept |
True if opened in append mode and file already existed.
Definition at line 406 of file fstreamPointer.H.
References Foam::noexcept.
Referenced by OFstream::is_appending().

|
inlinenoexcept |
True if file creation behaves as atomic.
Definition at line 414 of file fstreamPointer.H.
References Foam::noexcept.
Referenced by OFstream::is_atomic().

|
inlinenoexcept |
Return managed pointer and release ownership.
Definition at line 425 of file fstreamPointer.H.
References Foam::noexcept.
|
inlinenoexcept |
Replace the managed pointer.
Definition at line 434 of file fstreamPointer.H.
|
inline |
Reference to the stream (no nullptr checking).
Definition at line 446 of file fstreamPointer.H.
|
inline |
Const-reference to the stream (no nullptr checking).
Definition at line 451 of file fstreamPointer.H.
|
inlinenoexcept |
|
inlinenoexcept |