A wrapped std::ofstream
with possible compression handling (ogzstream) that behaves much like a std::unique_ptr
.
More...
Public Member Functions | |
ofstreamPointer (const ofstreamPointer &)=delete | |
No copy construct. More... | |
ofstreamPointer (ofstreamPointer &&)=default | |
Move construct. More... | |
void | operator= (const ofstreamPointer &)=delete |
No copy assignment. More... | |
ofstreamPointer & | operator= (ofstreamPointer &&)=default |
Move assignment. More... | |
~ofstreamPointer ()=default | |
Destructor. More... | |
ofstreamPointer () noexcept | |
Default construct (empty) More... | |
ofstreamPointer (std::nullptr_t) | |
Construct as null output stream (Foam::ocountstream) More... | |
ofstreamPointer (const fileName &pathname, IOstreamOption streamOpt=IOstreamOption(), IOstreamOption::appendType append=IOstreamOption::NO_APPEND, bool atomic=false) | |
Construct from pathname, option, append, file handling atomic. More... | |
ofstreamPointer (const fileName &pathname, IOstreamOption::compressionType comp, IOstreamOption::appendType append=IOstreamOption::NO_APPEND, bool atomic=false) | |
Construct from pathname, compression, append, file handling atomic. More... | |
operator bool () const noexcept | |
True if it holds a valid pointer. More... | |
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... | |
bool | is_appending () const noexcept |
True if opened in append mode and file already existed. More... | |
bool | is_atomic () const noexcept |
True if file creation behaves as atomic. 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 () noexcept |
True if compiled with libz support. More... | |
Protected Member Functions | |
void | reopen (const std::string &pathname) |
Reopen for compressed/non-compressed. Discards append status. More... | |
void | close (const std::string &pathname) |
Close stream and rename file. More... | |
A wrapped std::ofstream
with possible compression handling (ogzstream) that behaves much like a std::unique_ptr
.
operator bool
to avoid inheritance ambiguity with std::ios::operator bool
.Definition at line 239 of file fstreamPointer.H.
|
delete |
No copy construct.
|
default |
Move construct.
|
default |
Destructor.
|
noexcept |
Default construct (empty)
Definition at line 81 of file fstreamPointers.C.
|
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 96 of file fstreamPointers.C.
References append(), IOstreamOption::APPEND_APP, IOstreamOption::APPEND_ATE, IOstreamOption::COMPRESSED, IOstreamOption::compression(), stdFoam::end(), Foam::endl(), fileName::FILE, filePtr, Foam::nl, IOstreamOption::NO_APPEND, Foam::rm(), fileName::SYMLINK, Foam::type(), IOstreamOption::UNCOMPRESSED, 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 290 of file fstreamPointers.C.
|
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 |
No copy assignment.
|
default |
Move assignment.
|
staticnoexcept |
True if compiled with libz support.
Definition at line 46 of file fstreamPointers.C.
Referenced by Time::readDict().
|
inlineexplicitnoexcept |
True if it holds a valid pointer.
Definition at line 386 of file fstreamPointer.H.
|
inlinenoexcept |
The stream pointer (ofstream or ogzstream)
Definition at line 391 of file fstreamPointer.H.
Referenced by OFstream::rewind(), and OFstream::stdStream().
|
inlinenoexcept |
The stream pointer (ofstream or ogzstream)
Definition at line 396 of file fstreamPointer.H.
Foam::IOstreamOption::compressionType whichCompression | ( | ) | const |
Which compression type?
Definition at line 510 of file fstreamPointers.C.
|
inlinenoexcept |
True if opened in append mode and file already existed.
Definition at line 406 of file fstreamPointer.H.
Referenced by OFstream::is_appending().
|
inlinenoexcept |
True if file creation behaves as atomic.
Definition at line 414 of file fstreamPointer.H.
Referenced by OFstream::is_atomic().
|
inlinenoexcept |
Return managed pointer and release ownership.
Definition at line 425 of file fstreamPointer.H.
|
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 |
Pointer dereference.
Definition at line 456 of file fstreamPointer.H.
|
inlinenoexcept |
Pointer dereference.
Definition at line 461 of file fstreamPointer.H.