TarReader.h
1 /* Copyright (C) 2008 Marc Boris Duerner
2 
3  This library is free software; you can redistribute it and/or
4  modify it under the terms of the GNU Lesser General Public
5  License as published by the Free Software Foundation; either
6  version 2.1 of the License, or (at your option) any later version.
7 
8  As a special exception, you may use this file as part of a free
9  software library without restriction. Specifically, if other files
10  instantiate templates or use macros or inline functions from this
11  file, or you compile this file and link it with other files to
12  produce an executable, this file does not by itself cause the
13  resulting executable to be covered by the GNU General Public
14  License. This exception does not however invalidate any other
15  reasons why the executable file might be covered by the GNU Library
16  General Public License.
17 
18  This library is distributed in the hope that it will be useful,
19  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21  Lesser General Public License for more details.
22 
23  You should have received a copy of the GNU Lesser General Public
24  License along with this library; if not, write to the Free Software
25  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
26  MA 02110-1301 USA
27 */
28 
29 #ifndef PT_SYSTEM_TAR_READER_H
30 #define PT_SYSTEM_TAR_READER_H
31 
32 #include <Pt/System/Api.h>
33 #include <Pt/System/TarEntry.h>
34 
35 #include <istream>
36 #include <ios>
37 #include <cstddef>
38 
39 namespace Pt {
40 
41 namespace System {
42 
88 class PT_SYSTEM_API TarReader
89 {
90  public:
91  using Entry = TarEntry;
92 
93  public:
97 
100  explicit TarReader(std::istream& is);
101 
105 
108  void attach(std::istream& is);
109 
112  void detach();
113 
116  void reset();
117 
120  void reset(std::istream& is);
121 
138  const TarEntry* advance(std::streamsize importSize = 0);
139 
142  bool isEnd() const;
143 
144  private:
145  TarReader(const TarReader&);
146 
147  TarReader& operator=(const TarReader&);
148 
149  private:
150  class TarReaderImpl* _impl;
151 };
152 
153 } // namespace System
154 
155 } // namespace Pt
156 
157 #endif // include guard
Core module.
Definition: Allocator.h:33
Incremental reader for tar archives (Pax/UStar format).
Definition: TarReader.h:89
void reset(std::istream &is)
Reset state and attach to a new input stream.
TarReader(std::istream &is)
Constructor attaching to is.
void detach()
Detach from the current input stream.
TarReader()
Default constructor.
void attach(std::istream &is)
Attach to an input stream.
const TarEntry * advance(std::streamsize importSize=0)
Advance to the next entry or deliver the next content chunk.
bool isEnd() const
Returns true when the end-of-archive marker has been read.
void reset()
Reset state and detach from the input stream.
~TarReader()
Destructor.
Represents a single entry returned by TarReader.
Definition: TarEntry.h:62