trunk/branch integration: documentation

This commit is contained in:
Marian Krivos 2011-08-23 06:51:23 +00:00
parent 7f54dc2b35
commit 1e58e9e2a0

View File

@ -1,7 +1,7 @@
// //
// InflatingStream.h // InflatingStream.h
// //
// $Id: //poco/svn/Foundation/include/Poco/InflatingStream.h#2 $ // $Id: //poco/1.4/Foundation/include/Poco/InflatingStream.h#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Streams // Package: Streams
@ -44,34 +44,38 @@
#include "Poco/BufferedStreamBuf.h" #include "Poco/BufferedStreamBuf.h"
#include <istream> #include <istream>
#include <ostream> #include <ostream>
#if defined(POCO_UNBUNDLED)
#include <zlib.h>
#else
#include "Poco/zlib.h" #include "Poco/zlib.h"
#endif
namespace Poco { namespace Poco {
class Foundation_API InflatingStreamBuf: public BufferedStreamBuf class Foundation_API InflatingStreamBuf: public BufferedStreamBuf
/// This is the streambuf class used by InflatingInputStream and InflatingOutputStream. /// This is the streambuf class used by InflatingInputStream and InflatingOutputStream.
/// The actual work is delegated to zlib 1.2.1 (see http://www.gzip.org). /// The actual work is delegated to zlib (see http://zlib.net).
/// Both zlib (deflate) streams and gzip streams are supported. /// Both zlib (deflate) streams and gzip streams are supported.
/// Output streams should always call close() to ensure /// Output streams should always call close() to ensure
/// proper completion of decompression. /// proper completion of decompression.
{ {
public: public:
enum StreamType enum StreamType
{ {
STREAM_ZLIB, STREAM_ZLIB, /// Expect a zlib header, use Adler-32 checksum.
STREAM_GZIP, STREAM_GZIP, /// Expect a gzip header, use CRC-32 checksum.
STREAM_ZIP // ZIP is handled as STREAM_ZLIB, except that we do not check the ADLER32 value (must be checked by an outside class!) STREAM_ZIP /// STREAM_ZIP is handled as STREAM_ZLIB, except that we do not check the ADLER32 value (must be checked by caller)
}; };
InflatingStreamBuf(std::istream& istr, StreamType type);
InflatingStreamBuf(std::ostream& ostr, StreamType type);
~InflatingStreamBuf();
int close();
InflatingStreamBuf(std::istream& istr, StreamType type);
InflatingStreamBuf(std::ostream& ostr, StreamType type);
~InflatingStreamBuf();
int close();
protected: protected:
int readFromDevice(char* buffer, std::streamsize length); int readFromDevice(char* buffer, std::streamsize length);
int writeToDevice(const char* buffer, std::streamsize length); int writeToDevice(const char* buffer, std::streamsize length);
private: private:
@ -97,26 +101,26 @@ class Foundation_API InflatingIOS: public virtual std::ios
/// order of the stream buffer and base classes. /// order of the stream buffer and base classes.
{ {
public: public:
InflatingIOS(std::ostream& ostr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB); InflatingIOS(std::ostream& ostr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
InflatingIOS(std::istream& istr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB); InflatingIOS(std::istream& istr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
~InflatingIOS(); ~InflatingIOS();
InflatingStreamBuf* rdbuf(); InflatingStreamBuf* rdbuf();
protected: protected:
InflatingStreamBuf _buf; InflatingStreamBuf _buf;
}; };
class Foundation_API InflatingOutputStream: public InflatingIOS, public std::ostream class Foundation_API InflatingOutputStream: public InflatingIOS, public std::ostream
/// This stream decompresses all data passing through it /// This stream decompresses all data passing through it
/// using zlib's inflate algorithm. /// using zlib's inflate algorithm.
/// After all data has been written to the stream, close() /// After all data has been written to the stream, close()
/// must be called to ensure completion of decompression. /// must be called to ensure completion of decompression.
{ {
public: public:
InflatingOutputStream(std::ostream& ostr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB); InflatingOutputStream(std::ostream& ostr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
~InflatingOutputStream(); ~InflatingOutputStream();
int close(); int close();
}; };
@ -124,14 +128,14 @@ class Foundation_API InflatingInputStream: public InflatingIOS, public std::istr
/// This stream decompresses all data passing through it /// This stream decompresses all data passing through it
/// using zlib's inflate algorithm. /// using zlib's inflate algorithm.
/// Example: /// Example:
/// std::ifstream istr("data.gz", std::ios::binary); /// std::ifstream istr("data.gz", std::ios::binary);
/// InflatingInputStream inflater(istr, InflatingStreamBuf::STREAM_GZIP); /// InflatingInputStream inflater(istr, InflatingStreamBuf::STREAM_GZIP);
/// std::string data; /// std::string data;
/// istr >> data; /// istr >> data;
{ {
public: public:
InflatingInputStream(std::istream& istr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB); InflatingInputStream(std::istream& istr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
~InflatingInputStream(); ~InflatingInputStream();
}; };