OpenMS  2.7.0
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
GzipIfstream Class Reference

Decompresses files which are compressed in the gzip format (*.gzip) More...

#include <OpenMS/FORMAT/GzipIfstream.h>

Collaboration diagram for GzipIfstream:
[legend]

Public Member Functions

 GzipIfstream ()
 Default Constructor. More...
 
 GzipIfstream (const char *filename)
 Detailed constructor with filename. More...
 
virtual ~GzipIfstream ()
 Destructor. More...
 
size_t read (char *s, size_t n)
 Reads n bytes from the bzip2 compressed file into buffer s. More...
 
bool streamEnd () const
 indicates whether the read function can be used safely More...
 
bool isOpen () const
 returns whether a file is open. More...
 
void open (const char *filename)
 opens a file for reading (decompression) More...
 
void close ()
 closes current file. More...
 

Protected Member Functions

 GzipIfstream (const GzipIfstream &bzip2)
 not implemented More...
 
GzipIfstreamoperator= (const GzipIfstream &bzip2)
 

Protected Attributes

gzFile gzfile_
 a gzFile object(void*) . Necessary for decompression More...
 
int n_buffer_
 counts the last read duffer More...
 
int gzerror_
 saves the last returned error by the read function More...
 
bool stream_at_end_
 true if end of file is reached More...
 

Detailed Description

Decompresses files which are compressed in the gzip format (*.gzip)

Constructor & Destructor Documentation

◆ GzipIfstream() [1/3]

Default Constructor.

◆ GzipIfstream() [2/3]

GzipIfstream ( const char *  filename)
explicit

Detailed constructor with filename.

◆ ~GzipIfstream()

virtual ~GzipIfstream ( )
virtual

Destructor.

◆ GzipIfstream() [3/3]

GzipIfstream ( const GzipIfstream bzip2)
protected

not implemented

Member Function Documentation

◆ close()

void close ( )

closes current file.

◆ isOpen()

bool isOpen ( ) const
inline

returns whether a file is open.

References GzipIfstream::gzfile_.

Referenced by GzipInputStream::getIsOpen().

◆ open()

void open ( const char *  filename)

opens a file for reading (decompression)

Note
any previous open files will be closed first!

◆ operator=()

GzipIfstream& operator= ( const GzipIfstream bzip2)
protected

◆ read()

size_t read ( char *  s,
size_t  n 
)

Reads n bytes from the bzip2 compressed file into buffer s.

Parameters
sBuffer to be filled with the output
nThe size of the buffer s
Returns
The number of actually read bytes. If it is less than n, the end of the file was reached and the stream is closed
Note
This returns a raw byte stream that is *not* null-terminated. Be careful here.
The length of the buffer needs to at least n
Closes the stream if the end of file is reached. Check isOpen before reading from the file again
Exceptions
Exception::ConversionErroris thrown if decompression fails
Exception::IllegalArgumentis thrown if no file for decompression is given. This can happen even happen if a file was already open but read until the end.

◆ streamEnd()

bool streamEnd ( ) const
inline

indicates whether the read function can be used safely

Returns
true if end of file was reached. Otherwise false.

References GzipIfstream::stream_at_end_.

Member Data Documentation

◆ gzerror_

int gzerror_
protected

saves the last returned error by the read function

◆ gzfile_

gzFile gzfile_
protected

a gzFile object(void*) . Necessary for decompression

Referenced by GzipIfstream::isOpen().

◆ n_buffer_

int n_buffer_
protected

counts the last read duffer

◆ stream_at_end_

bool stream_at_end_
protected

true if end of file is reached

Referenced by GzipIfstream::streamEnd().