1998-07-14 08:06:50 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: zstream.h
|
|
|
|
// Purpose: Memory stream classes
|
|
|
|
// Author: Guilhem Lavaux
|
2003-09-26 16:07:22 -04:00
|
|
|
// Modified by: Mike Wetherell
|
1998-07-14 08:06:50 -04:00
|
|
|
// Created: 11/07/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Guilhem Lavaux
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-07-14 08:06:50 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_WXZSTREAM_H__
|
|
|
|
#define _WX_WXZSTREAM_H__
|
1998-07-14 08:06:50 -04:00
|
|
|
|
2003-08-09 08:38:21 -04:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
2002-08-31 07:29:13 -04:00
|
|
|
#pragma interface "zstream.h"
|
1998-07-14 08:06:50 -04:00
|
|
|
#endif
|
|
|
|
|
1999-01-04 13:34:42 -05:00
|
|
|
#include "wx/defs.h"
|
1999-01-04 08:52:06 -05:00
|
|
|
|
1999-06-15 16:21:59 -04:00
|
|
|
#if wxUSE_ZLIB && wxUSE_STREAMS
|
1999-01-04 08:52:06 -05:00
|
|
|
|
1999-08-20 18:52:21 -04:00
|
|
|
#include "wx/stream.h"
|
1998-07-14 08:06:50 -04:00
|
|
|
|
2003-09-26 16:07:22 -04:00
|
|
|
// Compression level
|
|
|
|
enum {
|
|
|
|
wxZ_DEFAULT_COMPRESSION = -1,
|
|
|
|
wxZ_NO_COMPRESSION = 0,
|
|
|
|
wxZ_BEST_SPEED = 1,
|
|
|
|
wxZ_BEST_COMPRESSION = 9
|
|
|
|
};
|
|
|
|
|
|
|
|
// Flags
|
|
|
|
enum {
|
2004-04-11 15:34:56 -04:00
|
|
|
#if WXWIN_COMPATIBILITY_2_4
|
|
|
|
wxZLIB_24COMPATIBLE = 4, // read v2.4.x data without error
|
|
|
|
#endif
|
|
|
|
wxZLIB_NO_HEADER = 0, // raw deflate stream, no header or checksum
|
|
|
|
wxZLIB_ZLIB = 1, // zlib header and checksum
|
|
|
|
wxZLIB_GZIP = 2, // gzip header and checksum, requires zlib 1.2.1+
|
|
|
|
wxZLIB_AUTO = 3 // autodetect header zlib or gzip
|
2003-09-26 16:07:22 -04:00
|
|
|
};
|
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
|
1998-07-14 08:06:50 -04:00
|
|
|
public:
|
2004-04-11 15:34:56 -04:00
|
|
|
wxZlibInputStream(wxInputStream& stream, int flags = wxZLIB_AUTO);
|
1998-07-14 08:06:50 -04:00
|
|
|
virtual ~wxZlibInputStream();
|
|
|
|
|
2003-09-26 16:07:22 -04:00
|
|
|
char Peek() { return wxInputStream::Peek(); }
|
2004-11-10 16:10:30 -05:00
|
|
|
wxFileOffset GetLength() const { return wxInputStream::GetLength(); }
|
2003-09-26 16:07:22 -04:00
|
|
|
|
2004-04-11 15:34:56 -04:00
|
|
|
static bool CanHandleGZip();
|
|
|
|
|
1998-07-14 08:06:50 -04:00
|
|
|
protected:
|
1998-10-14 13:36:50 -04:00
|
|
|
size_t OnSysRead(void *buffer, size_t size);
|
2004-09-26 09:18:46 -04:00
|
|
|
wxFileOffset OnSysTell() const { return m_pos; }
|
1998-07-24 13:13:47 -04:00
|
|
|
|
|
|
|
protected:
|
1998-07-14 08:06:50 -04:00
|
|
|
size_t m_z_size;
|
|
|
|
unsigned char *m_z_buffer;
|
1998-09-17 13:30:13 -04:00
|
|
|
struct z_stream_s *m_inflate;
|
2004-09-26 09:18:46 -04:00
|
|
|
wxFileOffset m_pos;
|
2004-04-11 15:34:56 -04:00
|
|
|
#if WXWIN_COMPATIBILITY_2_4
|
|
|
|
bool m_24compatibilty;
|
|
|
|
#endif
|
2003-01-02 18:38:11 -05:00
|
|
|
|
2004-04-11 15:34:56 -04:00
|
|
|
DECLARE_NO_COPY_CLASS(wxZlibInputStream)
|
1998-07-14 08:06:50 -04:00
|
|
|
};
|
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
|
1998-07-14 08:06:50 -04:00
|
|
|
public:
|
2003-12-20 23:28:45 -05:00
|
|
|
wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = wxZLIB_ZLIB);
|
2004-11-23 09:26:10 -05:00
|
|
|
virtual ~wxZlibOutputStream() { Close(); }
|
1998-07-14 08:06:50 -04:00
|
|
|
|
2003-09-26 16:07:22 -04:00
|
|
|
void Sync() { DoFlush(false); }
|
2004-11-23 09:26:10 -05:00
|
|
|
bool Close();
|
2004-11-10 16:10:30 -05:00
|
|
|
wxFileOffset GetLength() const { return m_pos; }
|
1998-07-14 08:06:50 -04:00
|
|
|
|
2004-04-11 15:34:56 -04:00
|
|
|
static bool CanHandleGZip();
|
|
|
|
|
1998-07-14 08:06:50 -04:00
|
|
|
protected:
|
1998-10-14 13:36:50 -04:00
|
|
|
size_t OnSysWrite(const void *buffer, size_t size);
|
2004-09-26 09:18:46 -04:00
|
|
|
wxFileOffset OnSysTell() const { return m_pos; }
|
2003-09-26 16:07:22 -04:00
|
|
|
|
|
|
|
virtual void DoFlush(bool final);
|
1998-07-24 13:13:47 -04:00
|
|
|
|
|
|
|
protected:
|
1998-07-14 08:06:50 -04:00
|
|
|
size_t m_z_size;
|
|
|
|
unsigned char *m_z_buffer;
|
1998-09-17 13:30:13 -04:00
|
|
|
struct z_stream_s *m_deflate;
|
2004-09-26 09:18:46 -04:00
|
|
|
wxFileOffset m_pos;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
2004-04-11 15:34:56 -04:00
|
|
|
DECLARE_NO_COPY_CLASS(wxZlibOutputStream)
|
1998-07-14 08:06:50 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1999-06-15 16:21:59 -04:00
|
|
|
// wxUSE_ZLIB && wxUSE_STREAMS
|
1999-01-04 08:52:06 -05:00
|
|
|
|
|
|
|
#endif
|
1999-07-09 11:30:31 -04:00
|
|
|
// _WX_WXZSTREAM_H__
|
|
|
|
|