Vector BLF
CompressedFile.h
1 /*
2  * Copyright (C) 2013 Tobias Lorenz.
3  * Contact: tobias.lorenz@gmx.net
4  *
5  * This file is part of Tobias Lorenz's Toolkit.
6  *
7  * Commercial License Usage
8  * Licensees holding valid commercial licenses may use this file in
9  * accordance with the commercial license agreement provided with the
10  * Software or, alternatively, in accordance with the terms contained in
11  * a written agreement between you and Tobias Lorenz.
12  *
13  * GNU General Public License 3.0 Usage
14  * Alternatively, this file may be used under the terms of the GNU
15  * General Public License version 3.0 as published by the Free Software
16  * Foundation and appearing in the file LICENSE.GPL included in the
17  * packaging of this file. Please review the following information to
18  * ensure the GNU General Public License version 3.0 requirements will be
19  * met: http://www.gnu.org/copyleft/gpl.html.
20  */
21 
22 #pragma once
23 
24 #include <Vector/BLF/platform.h>
25 
26 #include <fstream>
27 #include <mutex>
28 
29 #include <Vector/BLF/AbstractFile.h>
30 
31 #include <Vector/BLF/vector_blf_export.h>
32 
33 namespace Vector {
34 namespace BLF {
35 
41 class VECTOR_BLF_EXPORT CompressedFile final : public AbstractFile {
42  public:
43  CompressedFile() = default;
44  ~CompressedFile() override;
45  CompressedFile(const CompressedFile &) = delete;
46  CompressedFile & operator=(const CompressedFile &) = delete;
47  CompressedFile(CompressedFile &&) = delete;
48  CompressedFile & operator=(CompressedFile &&) = delete;
49 
50  std::streamsize gcount() const override;
51  void read(char * s, std::streamsize n) override;
52  std::streampos tellg() override;
53  void seekg(std::streamoff off, const std::ios_base::seekdir way = std::ios_base::cur) override;
54  void write(const char * s, std::streamsize n) override;
55  std::streampos tellp() override;
56  bool good() const override;
57  bool eof() const override;
58 
65  virtual void open(const char * filename, std::ios_base::openmode openMode);
66 
72  virtual bool is_open() const;
73 
77  virtual void close();
78 
84  virtual void seekp(std::streampos pos);
85 
86  private:
90  std::fstream m_file {};
91 
93  mutable std::mutex m_mutex {};
94 };
95 
96 }
97 }
Definition: CompressedFile.h:41
Definition: AbstractFile.h:36