OpenMS
Loading...
Searching...
No Matches
DecompressingInputStream.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: Julianus Pfeuffer, Timo Sachsenberg $
7// --------------------------------------------------------------------------
8
9#pragma once
10
12
13#include <memory>
14#include <optional>
15#include <string>
16
17namespace OpenMS
18{
28 class OPENMS_DLLAPI DecompressingInputStream :
29 public InputStream
30 {
31public:
32 enum class Format { GZIP, BZIP2 };
33
35 static std::optional<Format> detect(const unsigned char* head, Size size);
36
44 DecompressingInputStream(std::unique_ptr<InputStream> source, Format format, const std::string& name);
45
47
49 UInt64 curPos() const override;
50
52 Size readBytes(unsigned char* to_fill, Size max_to_read) override;
53
55 void cancel() override;
56
59
60private:
61 struct Impl;
62 std::unique_ptr<Impl> impl_;
63 };
64
65} // namespace OpenMS
Decompresses gzip or bzip2 data read from another InputStream, e.g. a remote object.
Definition DecompressingInputStream.h:30
DecompressingInputStream(std::unique_ptr< InputStream > source, Format format, const std::string &name)
Decompresses source, which holds data in format.
UInt64 curPos() const override
The number of decompressed bytes read so far.
DecompressingInputStream(const DecompressingInputStream &)=delete
static std::optional< Format > detect(const unsigned char *head, Size size)
The format whose magic bytes start head (1F 8B: gzip, "BZh": bzip2), if any.
std::unique_ptr< Impl > impl_
zlib/bzip2 state (their headers stay out of this one)
Definition DecompressingInputStream.h:62
void cancel() override
Cancels a blocking read of the source stream.
Format
Definition DecompressingInputStream.h:32
Size readBytes(unsigned char *to_fill, Size max_to_read) override
Reads up to max_to_read decompressed bytes into to_fill; 0 at the end of the data.
DecompressingInputStream & operator=(const DecompressingInputStream &)=delete
Internal byte stream shared by the XML compression adapters.
Definition InputStream.h:16
uint64_t UInt64
Unsigned integer type (64bit)
Definition Types.h:47
size_t Size
Size type e.g. used as variable which can hold result of size()
Definition Types.h:97
Main OpenMS namespace.
Definition openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19