21 #ifndef ZYPP_BASE_GZSTREAM_H 22 #define ZYPP_BASE_GZSTREAM_H 34 namespace gzstream_detail
56 : _zError( 0 ), _errno( 0 )
93 , _mode(
std::ios_base::openmode(0) )
94 ,
_buffer( (bufferSize_r?bufferSize_r:1), 0 )
107 {
return( _mode == std::ios_base::in ); }
111 {
return( _mode == std::ios_base::out ); }
114 open(
const char * name_r, std::ios_base::openmode mode_r = std::ios_base::in );
121 pos_type compressed_tell()
const;
136 overflow( int_type c = traits_type::eof() );
142 seekoff( off_type off_r, std::ios_base::seekdir way_r, std::ios_base::openmode )
143 {
return seekTo( off_r, way_r ); }
146 seekpos( pos_type pos_r, std::ios_base::openmode )
147 {
return seekTo( off_type(pos_r), std::ios_base::beg ); }
168 { gzerror( _file, &_error.
_zError ); }
171 zReadTo(
char * buffer_r, std::streamsize maxcount_r );
174 zWriteFrom(
const char * buffer_r, std::streamsize count_r );
177 zSeekTo( off_type off_r, std::ios_base::seekdir way_r );
183 seekTo( off_type off_r, std::ios_base::seekdir way_r );
198 template<
class TBStream,
class TStreamBuf>
208 : stream_type( NULL )
209 { this->init( &_streambuf ); }
213 : stream_type( NULL )
214 { this->init( &_streambuf ); this->open( file_r ); }
222 {
return _streambuf.isOpen(); }
227 if ( !_streambuf.open( file_r, defMode(*
this) ) )
228 this->setstate(std::ios_base::failbit);
236 if ( !_streambuf.close() )
237 this->setstate(std::ios_base::failbit);
245 {
return _streambuf.zError(); }
249 const streambuf_type&
251 {
return _streambuf; }
257 std::ios_base::openmode
259 {
return std::ios_base::in; }
261 std::ios_base::openmode
263 {
return std::ios_base::out; }
286 #endif // ZYPP_BASE_GZSTREAM_H
std::vector< char > buffer_type
gzstream_detail::fXstream< std::istream, gzstream_detail::fgzstreambuf > ifgzstream
istream reading gzip files as well as plain files.
fgzstreambuf(unsigned bufferSize_r=512)
virtual pos_type seekpos(pos_type pos_r, std::ios_base::openmode)
String related utilities and Regular expression matching.
int _errno
errno, valid if zError is Z_ERRNO
gzstream_detail::ZlibError ZlibError
int _fd
file descriptor of the compressed file
TStreamBuf streambuf_type
ZlibError zError() const
The last error returned fron zlib.
std::ios_base::openmode defMode(const std::ostream &str_r)
const std::string & _buffer
void open(const char *file_r)
Common template to define ifgzstream/ofgzstream reading/writing gzip files.
std::ios_base::openmode _mode
std::ostream & operator<<(std::ostream &str, const ZlibError &obj)
fXstream(const char *file_r)
gzstream_detail::fXstream< std::ostream, gzstream_detail::fgzstreambuf > ofgzstream
ostream writing gzip files.
int _zError
The zlib error code.
ZlibError zError() const
The last error returned retuned fron zlib.
virtual pos_type seekoff(off_type off_r, std::ios_base::seekdir way_r, std::ios_base::openmode)
streambuf_type _streambuf
std::ios_base::openmode defMode(const std::istream &str_r)
std::string strerror() const
Return string describing the zlib error code.
Easy-to use interface to the ZYPP dependency resolver.
Helper class to ship zlib errors.
const streambuf_type & getbuf() const
Similar to ios::rdbuf.
Streambuffer reading or writing gzip files.