ifstreamPointer Class Reference

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

Inheritance diagram for ifstreamPointer:
[legend]

Public Member Functions

 ifstreamPointer () noexcept=default
 Default construct (empty) More...
 
 ifstreamPointer (const ifstreamPointer &)=delete
 No copy construct. More...
 
 ifstreamPointer (ifstreamPointer &&)=default
 Move construct. More...
 
void operator= (const ifstreamPointer &)=delete
 No copy assignment. More...
 
ifstreamPointeroperator= (ifstreamPointer &&)=default
 Move assignment. More...
 
 ~ifstreamPointer ()=default
 Destructor. More...
 
 ifstreamPointer (const fileName &pathname)
 Construct from pathname. More...
 
std::istream * get () noexcept
 The stream pointer (ifstream or igzstream) More...
 
const std::istream * get () const noexcept
 The stream pointer (ifstream or igzstream) More...
 
IOstreamOption::compressionType whichCompression () const
 Which compression type? More...
 
std::istream * release () noexcept
 Return managed pointer and release ownership. More...
 
void reset (std::istream *ptr) noexcept
 Replace the managed pointer. More...
 
std::istream & operator* ()
 Reference to the stream (no nullptr checking) More...
 
const std::istream & operator* () const
 Const-reference to the stream (no nullptr checking) More...
 
std::istream * operator-> () noexcept
 Pointer dereference. More...
 
const std::istream * 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...
 

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 71 of file fstreamPointer.H.

Constructor & Destructor Documentation

◆ ifstreamPointer() [1/4]

ifstreamPointer ( )
defaultnoexcept

Default construct (empty)

◆ ifstreamPointer() [2/4]

ifstreamPointer ( const ifstreamPointer )
delete

No copy construct.

◆ ifstreamPointer() [3/4]

ifstreamPointer ( ifstreamPointer &&  )
default

Move construct.

◆ ~ifstreamPointer()

~ifstreamPointer ( )
default

Destructor.

◆ ifstreamPointer() [4/4]

ifstreamPointer ( const fileName pathname)
explicit

Construct from pathname.

Definition at line 95 of file fstreamPointers.C.

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

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 194 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.

◆ operator=() [2/2]

ifstreamPointer & operator= ( ifstreamPointer &&  )
default

Move assignment.

◆ supports_gz()

bool supports_gz ( )
static

True if compiled with libz support.

Definition at line 73 of file fstreamPointers.C.

◆ get() [1/2]

std::istream * get ( )
inlinenoexcept

The stream pointer (ifstream or igzstream)

Definition at line 123 of file fstreamPointer.H.

Referenced by IFstream::IFstream(), IFstream::rewind(), 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 126 of file fstreamPointer.H.

◆ whichCompression()

Foam::IOstreamOption::compressionType whichCompression ( ) const

Which compression type?

Definition at line 243 of file fstreamPointers.C.

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

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

Here is the caller graph for this function:

◆ release()

std::istream * release ( )
inlinenoexcept

Return managed pointer and release ownership.

Definition at line 135 of file fstreamPointer.H.

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 138 of file fstreamPointer.H.

◆ operator*() [1/2]

std::istream & operator* ( )
inline

Reference to the stream (no nullptr checking)

Definition at line 144 of file fstreamPointer.H.

◆ operator*() [2/2]

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

Const-reference to the stream (no nullptr checking)

Definition at line 147 of file fstreamPointer.H.

◆ operator->() [1/2]

std::istream * operator-> ( )
inlinenoexcept

Pointer dereference.

Definition at line 150 of file fstreamPointer.H.

◆ operator->() [2/2]

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

Pointer dereference.

Definition at line 153 of file fstreamPointer.H.


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