OpenMS
GzipInputStream.h
Go to the documentation of this file.
1 // Copyright (c) 2002-present, The OpenMS Team -- 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>
13 
14 #include <xercesc/util/BinInputStream.hpp>
15 #include <xercesc/util/PlatformUtils.hpp>
16 
17 namespace OpenMS
18 {
19  class String;
20 
25  class OPENMS_DLLAPI GzipInputStream :
26  public xercesc::BinInputStream
27  {
28 public:
30  explicit GzipInputStream(const String& file_name);
31 
32  explicit GzipInputStream(const char* const file_name);
33 
35  ~GzipInputStream() override;
36 
38  bool getIsOpen() const;
39 
45  XMLFilePos curPos() const override;
46 
58  XMLSize_t readBytes(XMLByte* const to_fill, const XMLSize_t max_to_read) override;
59 
70  const XMLCh* getContentType() const override;
71 
72  GzipInputStream() = delete;
73  GzipInputStream(const GzipInputStream& stream) = delete;
74  GzipInputStream& operator=(const GzipInputStream& stream) = delete;
75 
76 private:
78  GzipIfstream* gzip_ = nullptr;
81  };
82 
83  inline XMLFilePos GzipInputStream::curPos() const
84  {
85  return file_current_index_;
86  }
87 
88  inline bool GzipInputStream::getIsOpen() const
89  {
90  return gzip_->isOpen();
91  }
92 
93 } // namespace OpenMS
94 
Decompresses files which are compressed in the gzip format (*.gzip)
Definition: GzipIfstream.h:21
bool isOpen() const
returns whether a file is open.
Definition: GzipIfstream.h:111
Implements the BinInputStream class of the xerces-c library in order to read gzip compressed XML file...
Definition: GzipInputStream.h:27
GzipIfstream * gzip_
pointer to an compression stream
Definition: GzipInputStream.h:78
~GzipInputStream() override
Destructor.
bool getIsOpen() const
returns true if file is open
Definition: GzipInputStream.h:88
const XMLCh * getContentType() const override
returns 0
XMLSize_t file_current_index_
current index of the actual file
Definition: GzipInputStream.h:80
GzipInputStream(const GzipInputStream &stream)=delete
XMLSize_t readBytes(XMLByte *const to_fill, const XMLSize_t max_to_read) override
writes bytes into buffer from file
XMLFilePos curPos() const override
returns the current position in the file
Definition: GzipInputStream.h:83
GzipInputStream(const String &file_name)
Constructor.
GzipInputStream & operator=(const GzipInputStream &stream)=delete
GzipInputStream(const char *const file_name)
A more convenient string class.
Definition: String.h:34
Main OpenMS namespace.
Definition: openswathalgo/include/OpenMS/OPENSWATHALGO/DATAACCESS/ISpectrumAccess.h:19