Loading...
Searching...
No Matches
ifstreamPointer Class Reference

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

#include <fstreamPointer.H>

Inheritance diagram for ifstreamPointer:

Public Member Functions

 ifstreamPointer () noexcept=default
 Default construct (empty).
 ifstreamPointer (const ifstreamPointer &)=delete
 No copy construct.
 ifstreamPointer (ifstreamPointer &&)=default
 Move construct.
void operator= (const ifstreamPointer &)=delete
 No copy assignment.
ifstreamPointeroperator= (ifstreamPointer &&)=default
 Move assignment.
 ~ifstreamPointer ()=default
 Destructor.
 ifstreamPointer (const fileName &pathname)
 Construct from pathname.
 ifstreamPointer (const fileName &pathname, IOstreamOption streamOpt)
 Construct from pathname, option.
 operator bool () const noexcept
 True if it holds a valid pointer.
std::istream * get () noexcept
 The stream pointer (ifstream or igzstream).
const std::istream * get () const noexcept
 The stream pointer (ifstream or igzstream).
IOstreamOption::compressionType whichCompression () const
 Which compression type?
void open (const fileName &pathname, IOstreamOption streamOpt=IOstreamOption())
 Attempts to open the specified file for reading.
std::istream * release () noexcept
 Return managed pointer and release ownership.
void reset (std::istream *ptr) noexcept
 Replace the managed pointer.
std::istream & operator* ()
 Reference to the stream (no nullptr checking).
const std::istream & operator* () const
 Const-reference to the stream (no nullptr checking).
std::istream * operator-> () noexcept
 Pointer dereference.
const std::istream * 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_gz (const std::string &pathname)
 Special 'rewind' method for compressed stream.

Detailed Description

A wrapped std::ifstream with possible compression handling (igzstream) 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 70 of file fstreamPointer.H.

Constructor & Destructor Documentation

◆ ifstreamPointer() [1/5]

ifstreamPointer ( )
defaultnoexcept

Default construct (empty).

References Foam::noexcept.

Referenced by IFstream::IFstream(), ifstreamPointer(), ifstreamPointer(), operator=(), operator=(), and ~ifstreamPointer().

Here is the caller graph for this function:

◆ ifstreamPointer() [2/5]

ifstreamPointer ( const ifstreamPointer & )
delete

No copy construct.

References ifstreamPointer().

Here is the call graph for this function:

◆ ifstreamPointer() [3/5]

ifstreamPointer ( ifstreamPointer && )
default

Move construct.

References ifstreamPointer().

Here is the call graph for this function:

◆ ~ifstreamPointer()

~ifstreamPointer ( )
default

Destructor.

References ifstreamPointer(), Foam::noexcept, and supports_gz().

Here is the call graph for this function:

◆ ifstreamPointer() [4/5]

ifstreamPointer ( const fileName & pathname)
explicit

Construct from pathname.

Attempts to read the specified file. If that fails, try as a compressed file (.gz ending).

Parameters
pathnameThe file name to open for reading

Definition at line 70 of file fstreamPointers.C.

References open().

Here is the call graph for this function:

◆ ifstreamPointer() [5/5]

ifstreamPointer ( const fileName & pathname,
IOstreamOption streamOpt )

Construct from pathname, option.

Attempts to read the specified file. If that fails, try as a compressed file (.gz ending).

Parameters
pathnameThe file name to open for reading
streamOptCurrently unused

Definition at line 58 of file fstreamPointers.C.

References open().

Here is the call graph for this function:

Member Function Documentation

◆ reopen_gz()

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

Special 'rewind' method for compressed stream.

Definition at line 359 of file fstreamPointers.C.

Referenced by IFstream::rewind().

Here is the caller graph for this function:

◆ operator=() [1/2]

void operator= ( const ifstreamPointer & )
delete

No copy assignment.

References ifstreamPointer().

Here is the call graph for this function:

◆ operator=() [2/2]

ifstreamPointer & operator= ( ifstreamPointer && )
default

Move assignment.

References ifstreamPointer().

Here is the call graph for this function:

◆ supports_gz()

bool supports_gz ( )
staticnoexcept

True if compiled with libz support.

Definition at line 36 of file fstreamPointers.C.

References Foam::noexcept.

Referenced by ~ifstreamPointer().

Here is the caller graph for this function:

◆ operator bool()

operator bool ( ) const
inlineexplicitnoexcept

True if it holds a valid pointer.

Definition at line 164 of file fstreamPointer.H.

References Foam::noexcept.

◆ get() [1/2]

std::istream * get ( )
inlinenoexcept

The stream pointer (ifstream or igzstream).

Definition at line 169 of file fstreamPointer.H.

References Foam::noexcept.

Referenced by IFstream::fileSize(), IFstream::IFstream(), IFstream::rewind(), IFstream::stdStream(), and IFstream::stdStream().

Here is the caller graph for this function:

◆ get() [2/2]

const std::istream * get ( ) const
inlinenoexcept

The stream pointer (ifstream or igzstream).

Definition at line 174 of file fstreamPointer.H.

References Foam::noexcept.

◆ whichCompression()

Foam::IOstreamOption::compressionType whichCompression ( ) const

Which compression type?

Definition at line 496 of file fstreamPointers.C.

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

Referenced by STLCore::detectBinaryHeader(), IFstream::fileSize(), IFstream::IFstream(), STLCore::readBinaryHeader(), and IFstream::rewind().

Here is the caller graph for this function:

◆ open()

void open ( const fileName & pathname,
IOstreamOption streamOpt = IOstreamOption() )

Attempts to open the specified file for reading.

If that fails, try as a compressed file (.gz ending).

Parameters
pathnameThe file name to open for reading
streamOptCurrently unused

Definition at line 309 of file fstreamPointers.C.

References Foam::endl(), Foam::exit(), Foam::FatalError, Foam::isFile(), and Foam::nl.

Referenced by ifstreamPointer(), and ifstreamPointer().

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

◆ release()

std::istream * release ( )
inlinenoexcept

Return managed pointer and release ownership.

Definition at line 203 of file fstreamPointer.H.

References Foam::noexcept.

Referenced by STLCore::readBinaryHeader().

Here is the caller graph for this function:

◆ reset()

void reset ( std::istream * ptr)
inlinenoexcept

Replace the managed pointer.

Definition at line 208 of file fstreamPointer.H.

◆ operator*() [1/2]

std::istream & operator* ( )
inline

Reference to the stream (no nullptr checking).

Definition at line 216 of file fstreamPointer.H.

◆ operator*() [2/2]

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

Const-reference to the stream (no nullptr checking).

Definition at line 221 of file fstreamPointer.H.

◆ operator->() [1/2]

std::istream * operator-> ( )
inlinenoexcept

Pointer dereference.

Definition at line 226 of file fstreamPointer.H.

References Foam::noexcept.

◆ operator->() [2/2]

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

Pointer dereference.

Definition at line 231 of file fstreamPointer.H.

References Foam::noexcept.


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