Home  · Classes  · Annotated Classes  · Modules  · Members  · Namespaces  · Related Pages
Public Member Functions | Protected Member Functions | Protected Attributes

Bzip2Ifstream Class Reference

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

#include <OpenMS/FORMAT/Bzip2Ifstream.h>

List of all members.

Public Member Functions

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

Protected Member Functions

 Bzip2Ifstream (const Bzip2Ifstream &bzip2)
Bzip2Ifstreamoperator= (const Bzip2Ifstream &bzip2)

Protected Attributes

FILE * file_
 pointer to a FILE object. Necessary for opening the file
BZFILE * bzip2file_
 a pointer to a BZFILE object. Necessary for decompression
size_t n_buffer_
 counts the last read buffer
int bzerror_
 saves the last returned error by the read function
bool stream_at_end_
 true if end of file is reached

Detailed Description

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


Constructor & Destructor Documentation

Bzip2Ifstream (  ) 

Default Constructor.

Bzip2Ifstream ( const char *  filename  ) 

Detailed constructor with filename.

virtual ~Bzip2Ifstream (  )  [virtual]

Destructor.

Bzip2Ifstream ( const Bzip2Ifstream bzip2  )  [protected]

Member Function Documentation

void close (  ) 

closes current file.

bool isOpen (  )  const [inline]

returns whether a file is open.

References Bzip2Ifstream::file_.

Referenced by Bzip2InputStream::getIsOpen().

void open ( const char *  filename  ) 

opens a file for reading (decompression)

Note:
any previous open files will be closed first!
Bzip2Ifstream& operator= ( const Bzip2Ifstream bzip2  )  [protected]
size_t read ( char *  s,
size_t  n 
)

reads n bytes from the bzip2 compressed file into buffer s

Parameters:
s will be filled with bytes
n is the size of the buffer s
Returns:
the number of actually read bytes. If it is 0 the end of the file was reached and the stream is closed
Exceptions:
Exception::ConversionError is thrown if decompression fails
Exception::IllegalArgument is thrown if no file for decompression is given. This can happen even happen if a file was already open but read until the end.
Note:
it is undefined what will happen if parameter n is bigger than the length of the buffer
bool streamEnd (  )  const [inline]

indicates whether the read function can be used safely

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

References Bzip2Ifstream::stream_at_end_.


Member Data Documentation

int bzerror_ [protected]

saves the last returned error by the read function

BZFILE* bzip2file_ [protected]

a pointer to a BZFILE object. Necessary for decompression

FILE* file_ [protected]

pointer to a FILE object. Necessary for opening the file

Referenced by Bzip2Ifstream::isOpen().

size_t n_buffer_ [protected]

counts the last read buffer

bool stream_at_end_ [protected]

true if end of file is reached

Referenced by Bzip2Ifstream::streamEnd().


OpenMS / TOPP release 1.10.0 Documentation generated on Thu Mar 7 2013 09:42:53 using doxygen 1.7.1