OpenMS
Loading...
Searching...
No Matches
Bzip2Ifstream.h
Go to the documentation of this file.
1// Copyright (c) 2002-present, OpenMS Inc. -- EKU Tuebingen, ETH Zurich, and FU Berlin
2// SPDX-License-Identifier: BSD-3-Clause
3//
4// --------------------------------------------------------------------------
5// $Maintainer: Timo Sachsenberg $
6// $Authors: David Wojnar $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/config.h>
12#include <bzlib.h>
13#include <istream>
14
15namespace OpenMS
16{
32 class OPENMS_DLLAPI Bzip2Ifstream
33 {
34public:
37
50 explicit Bzip2Ifstream(const char * filename);
51
53 virtual ~Bzip2Ifstream();
54
75 size_t read(char * s, size_t n);
76
82 bool streamEnd() const;
83
89 bool isOpen() const;
90
101 void open(const char * filename);
102
104 void close();
105
106protected:
108 FILE * file_;
110 BZFILE * bzip2file_;
112 size_t n_buffer_;
117
118 //not implemented
121 };
122
123 //return bzip2file???!!!!????
124 inline bool Bzip2Ifstream::isOpen() const
125 {
126 return file_ != nullptr;
127 }
128
129 inline bool Bzip2Ifstream::streamEnd() const
130 {
131 return stream_at_end_;
132 }
133
134} //namespace OpenMS
Streaming decompressor for bzip2 (.bz2) files.
Definition Bzip2Ifstream.h:33
bool isOpen() const
Whether a file is currently open for reading.
Definition Bzip2Ifstream.h:124
Bzip2Ifstream(const char *filename)
Construct and open filename for reading in one step.
Bzip2Ifstream(const Bzip2Ifstream &bzip2)
int bzerror_
Most recent bzip2 status code returned to the read API.
Definition Bzip2Ifstream.h:114
Bzip2Ifstream()
Default constructor; leaves the instance in a closed state (isOpen returns false, streamEnd returns t...
void open(const char *filename)
Open filename for reading; closes the currently open file first.
void close()
Close the currently open file (no-op if none is open). After the call, isOpen returns false and strea...
bool stream_at_end_
true once the stream has been closed (either explicitly via close or implicitly because the end of th...
Definition Bzip2Ifstream.h:116
FILE * file_
Underlying FILE handle used to feed the bzip2 reader; nullptr when no file is open.
Definition Bzip2Ifstream.h:108
size_t read(char *s, size_t n)
Read up to n decompressed bytes into s.
virtual ~Bzip2Ifstream()
Destructor; closes the bzip2 reader and the underlying file handle.
BZFILE * bzip2file_
bzip2 read handle attached to file_; nullptr when no file is open.
Definition Bzip2Ifstream.h:110
size_t n_buffer_
Number of bytes produced by the most recent read call.
Definition Bzip2Ifstream.h:112
Bzip2Ifstream & operator=(const Bzip2Ifstream &bzip2)
bool streamEnd() const
Whether the stream has been closed (end of file reached or no file opened).
Definition Bzip2Ifstream.h:129
Under certain circumstances you may want to build all dependencies from source code In order to facilitate the installation of the libraries required for OpenMS we provide a contrib package containing the following bzip2
Definition install-contrib.doxygen:5
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19