From: Christian P. <cp...@us...> - 2005-01-06 18:30:42
|
Update of /cvsroot/pclasses/pclasses2/include/pclasses/IO In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6341/include/pclasses/IO Added Files: BZip2.h Log Message: Added bzip2 support. --- NEW FILE: BZip2.h --- /*************************************************************************** * Copyright (C) 2004 by Christian Prochnow * * cp...@se... * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * * published by the Free Software Foundation; either version 2 of the * * License, or (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU Library General Public * * License along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #ifndef P_IO_BZip2_h #define P_IO_BZip2_h #include <pclasses/Exception.h> #include <pclasses/IntTypes.h> #include <string> namespace P { namespace IO { //! BZip2 error class BZip2Error: public RuntimeError { public: BZip2Error(int err, const char* what, const SourceInfo& si); ~BZip2Error(); int errorNo() const throw(); std::string msg() const throw(); private: int _err; }; //! Bzip2 stream base class BZip2Stream { public: BZip2Stream(size_t bufferSize); virtual ~BZip2Stream(); //! Number of bytes available to consume size_t bytesAvail() const throw(); //! Returns a pointer to the produced data const char* buffer() const throw(); //! Dequeue produced data size_t dequeue(size_t count) throw(BZip2Error); //! Put data into producer buffer void put(const char* buffer, size_t count) throw(BZip2Error); protected: void* _strm; char* _buffer; size_t _bufferSize; }; //! BZip2 output (deflate) stream class BZip2OutputStream: public BZip2Stream { public: BZip2OutputStream(int level = 6, size_t bufferSize = 1024) throw(BZip2Error); ~BZip2OutputStream() throw(); //! Compress buffer into output buffer /*! Returns the number of bytes actually deflated. */ size_t compress(const char* buffer, size_t count) throw(BZip2Error); void sync() throw(BZip2Error); //! Finish compression and reset state bool finish() throw(BZip2Error); //! Reset stream void reset() throw(BZip2Error); }; //! BZip2 input (inflate) stream class BZip2InputStream: public BZip2Stream { public: BZip2InputStream(size_t bufferSize = 1024) throw(BZip2Error); ~BZip2InputStream() throw(); //! Decompress buffer into output buffer /*! Returns the number of bytes actually inflated, which may be NULL when <count> is NULL or the end of the stream has been reached. */ size_t decompress(const char* buffer, size_t count) throw(BZip2Error); bool eof() const throw(); //! Reset stream void reset() throw(BZip2Error); private: bool _eof; }; } // !namespace IO } // !namespace P #endif |