libzypp: zypp-core/base/zckstream.h Source File

libzypp 17.38.7

zckstream.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
9#ifndef ZYPP_CORE_BASE_ZCKSTREAM_H
10#define ZYPP_CORE_BASE_ZCKSTREAM_H
11
12#include <iosfwd>
13#include <streambuf>
14#include <vector>
15#include <zypp-core/base/SimpleStreambuf>
16#include <zypp-core/base/fXstream>
17
18 using zckCtx = struct zckCtx;
19
20namespace zypp {
21
22 namespace detail {
23
31 class zckstreambufimpl {
32 public:
33
34 using error_type = std::string;
35
36 ~zckstreambufimpl();
37
38 bool isOpen () const;
39 bool canRead () const;
40 bool canWrite () const;
41 bool canSeek ( std::ios_base::seekdir way_r ) const;
42
43 std::streamsize readData ( char * buffer_r, std::streamsize maxcount_r );
44 bool writeData( const char * buffer_r, std::streamsize count_r );
45 off_t seekTo( off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r );
46 off_t tell() const;
47
48 error_type error() const { return _lastErr; }
49
50 protected:
51 bool openImpl( const char * name_r, std::ios_base::openmode mode_r );
52 bool closeImpl ();
53
54 private:
55 void setError ();
56 int _fd = -1;
57 bool _isReading = false;
58 zckCtx *_zContext = nullptr;
59 off_t _currfp = 0;
60 error_type _lastErr;
61
62 };
63 using ZChunkStreamBuf = detail::SimpleStreamBuf<detail::zckstreambufimpl>;
64 }
65
69 using ifzckstream = detail::fXstream<std::istream,detail::ZChunkStreamBuf>;
70
74 using ofzckstream = detail::fXstream<std::ostream,detail::ZChunkStreamBuf>;
75}
76
77#endif
zypp::detail::SimpleStreamBuf
Definition simplestreambuf.h:55
zypp::detail::fXstream
Common template to define ifgzstream/ofgzstream reading/writing compressed files.
Definition fxstream.h:27
zypp::detail::zckstreambufimpl
Streambuffer reading or writing zchunk files.
Definition zckstream.h:31
zypp::detail::zckstreambufimpl::_lastErr
error_type _lastErr
Definition zckstream.h:60
zypp::detail::zckstreambufimpl::_fd
int _fd
Definition zckstream.h:56
zypp::detail::zckstreambufimpl::error_type
std::string error_type
Definition zckstream.h:34
zypp::detail::zckstreambufimpl::canRead
bool canRead() const
Definition zckstream.cc:137
zypp::detail::zckstreambufimpl::tell
off_t tell() const
Definition zckstream.cc:157
zypp::detail::zckstreambufimpl::canSeek
bool canSeek(std::ios_base::seekdir way_r) const
Definition zckstream.cc:147
zypp::detail::zckstreambufimpl::_isReading
bool _isReading
Definition zckstream.h:57
zypp::detail::zckstreambufimpl::_zContext
zckCtx * _zContext
Definition zckstream.h:58
zypp::detail::zckstreambufimpl::readData
std::streamsize readData(char *buffer_r, std::streamsize maxcount_r)
Definition zckstream.cc:104
zypp::detail::zckstreambufimpl::_currfp
off_t _currfp
Definition zckstream.h:59
zypp::detail::zckstreambufimpl::setError
void setError()
Definition zckstream.cc:96
zypp::detail::zckstreambufimpl::error
error_type error() const
Definition zckstream.h:48
zypp::detail::zckstreambufimpl::seekTo
off_t seekTo(off_t off_r, std::ios_base::seekdir way_r, std::ios_base::openmode omode_r)
Definition zckstream.cc:152
zypp::detail::zckstreambufimpl::writeData
bool writeData(const char *buffer_r, std::streamsize count_r)
Definition zckstream.cc:118
zypp::detail::zckstreambufimpl::isOpen
bool isOpen() const
Definition zckstream.cc:132
zypp::detail::zckstreambufimpl::~zckstreambufimpl
~zckstreambufimpl()
Definition zckstream.cc:26
zypp::detail::zckstreambufimpl::openImpl
bool openImpl(const char *name_r, std::ios_base::openmode mode_r)
Definition zckstream.cc:31
zypp::detail::zckstreambufimpl::canWrite
bool canWrite() const
Definition zckstream.cc:142
zypp::detail::zckstreambufimpl::closeImpl
bool closeImpl()
Definition zckstream.cc:77
zypp::detail::ZChunkStreamBuf
detail::SimpleStreamBuf< detail::zckstreambufimpl > ZChunkStreamBuf
Definition zckstream.h:63
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::ofzckstream
detail::fXstream< std::ostream, detail::ZChunkStreamBuf > ofzckstream
ostream writing zchunk files.
Definition zckstream.h:74
zypp::ifzckstream
detail::fXstream< std::istream, detail::ZChunkStreamBuf > ifzckstream
istream reading zchunk files.
Definition zckstream.h:69
zckCtx
struct zckCtx zckCtx
Definition zckstream.h:18