OpenMS
Loading...
Searching...
No Matches
ZipIfstream.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: Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
11#include <OpenMS/config.h>
12
13#include <cstddef>
14
15namespace OpenMS
16{
24 class OPENMS_DLLAPI ZipIfstream
25 {
26public:
29
31 explicit ZipIfstream(const char* filename);
32
34 virtual ~ZipIfstream();
35
46 size_t read(char* s, size_t n);
47
53 bool streamEnd() const;
54
58 bool isOpen() const;
59
69 void open(const char* filename);
70
74 void close();
75
76 ZipIfstream(const ZipIfstream&) = delete;
80
81protected:
83 void* zip_archive_ = nullptr;
84 void* zip_entry_ = nullptr;
86 bool stream_at_end_ = true;
87 };
88
89 inline bool ZipIfstream::isOpen() const
90 {
91 return zip_entry_ != nullptr;
92 }
93
94 inline bool ZipIfstream::streamEnd() const
95 {
96 return stream_at_end_;
97 }
98
99} // namespace OpenMS
Decompresses a single-entry ZIP archive for streaming reading.
Definition ZipIfstream.h:25
bool isOpen() const
returns whether a file is open.
Definition ZipIfstream.h:89
ZipIfstream(const char *filename)
Detailed constructor with filename.
void * zip_entry_
Definition ZipIfstream.h:84
virtual ~ZipIfstream()
Destructor.
ZipIfstream & operator=(const ZipIfstream &)=delete
void open(const char *filename)
opens a ZIP archive for reading from its single non-directory entry
void close()
closes current file.
bool stream_at_end_
true if end of entry is reached
Definition ZipIfstream.h:86
size_t read(char *s, size_t n)
Reads n bytes from the zip entry into buffer s.
ZipIfstream(ZipIfstream &&)=delete
ZipIfstream()
Default Constructor.
ZipIfstream(const ZipIfstream &)=delete
bool streamEnd() const
indicates whether the read function can be used safely
Definition ZipIfstream.h:94
ZipIfstream & operator=(ZipIfstream &&)=delete
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19