1998-07-14 12:06:50 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: zstream.h
|
|
|
|
// Purpose: Memory stream classes
|
|
|
|
// Author: Guilhem Lavaux
|
2003-09-26 20:07:22 +00:00
|
|
|
// Modified by: Mike Wetherell
|
1998-07-14 12:06:50 +00:00
|
|
|
// Created: 11/07/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Guilhem Lavaux
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_WXZSTREAM_H__
|
|
|
|
#define _WX_WXZSTREAM_H__
|
1998-07-14 12:06:50 +00:00
|
|
|
|
2003-08-09 12:38:21 +00:00
|
|
|
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
|
2002-08-31 11:29:13 +00:00
|
|
|
#pragma interface "zstream.h"
|
1998-07-14 12:06:50 +00:00
|
|
|
#endif
|
|
|
|
|
1999-01-04 18:34:42 +00:00
|
|
|
#include "wx/defs.h"
|
1999-01-04 13:52:06 +00:00
|
|
|
|
1999-06-15 20:21:59 +00:00
|
|
|
#if wxUSE_ZLIB && wxUSE_STREAMS
|
1999-01-04 13:52:06 +00:00
|
|
|
|
1999-08-20 22:52:21 +00:00
|
|
|
#include "wx/stream.h"
|
1998-07-14 12:06:50 +00:00
|
|
|
|
2003-09-26 20:07:22 +00:00
|
|
|
// Compression level
|
|
|
|
enum {
|
|
|
|
wxZ_DEFAULT_COMPRESSION = -1,
|
|
|
|
wxZ_NO_COMPRESSION = 0,
|
|
|
|
wxZ_BEST_SPEED = 1,
|
|
|
|
wxZ_BEST_COMPRESSION = 9
|
|
|
|
};
|
|
|
|
|
|
|
|
// Flags
|
|
|
|
enum {
|
|
|
|
wxZLIB_NO_HEADER = 1 // required for use in Gzip and Zip files
|
|
|
|
};
|
|
|
|
|
2003-07-02 01:59:24 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxZlibInputStream: public wxFilterInputStream {
|
1998-07-14 12:06:50 +00:00
|
|
|
public:
|
2003-09-26 20:07:22 +00:00
|
|
|
wxZlibInputStream(wxInputStream& stream, int flags = 0);
|
1998-07-14 12:06:50 +00:00
|
|
|
virtual ~wxZlibInputStream();
|
|
|
|
|
2003-09-26 20:07:22 +00:00
|
|
|
char Peek() { return wxInputStream::Peek(); }
|
|
|
|
size_t GetSize() const { return wxInputStream::GetSize(); }
|
|
|
|
|
1998-07-14 12:06:50 +00:00
|
|
|
protected:
|
1998-10-14 17:36:50 +00:00
|
|
|
size_t OnSysRead(void *buffer, size_t size);
|
2003-09-26 20:07:22 +00:00
|
|
|
off_t OnSysTell() const { return m_pos; }
|
1998-07-24 17:13:47 +00:00
|
|
|
|
|
|
|
protected:
|
1998-07-14 12:06:50 +00:00
|
|
|
size_t m_z_size;
|
|
|
|
unsigned char *m_z_buffer;
|
1998-09-17 17:30:13 +00:00
|
|
|
struct z_stream_s *m_inflate;
|
2003-09-26 20:07:22 +00:00
|
|
|
off_t m_pos;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxZlibInputStream)
|
1998-07-14 12:06:50 +00:00
|
|
|
};
|
|
|
|
|
2003-07-02 01:59:24 +00:00
|
|
|
class WXDLLIMPEXP_BASE wxZlibOutputStream: public wxFilterOutputStream {
|
1998-07-14 12:06:50 +00:00
|
|
|
public:
|
2003-09-26 20:07:22 +00:00
|
|
|
wxZlibOutputStream(wxOutputStream& stream, int level = -1, int flags = 0);
|
1998-07-14 12:06:50 +00:00
|
|
|
virtual ~wxZlibOutputStream();
|
|
|
|
|
2003-09-26 20:07:22 +00:00
|
|
|
void Sync() { DoFlush(false); }
|
|
|
|
size_t GetSize() const { return (size_t)m_pos; }
|
1998-07-14 12:06:50 +00:00
|
|
|
|
|
|
|
protected:
|
1998-10-14 17:36:50 +00:00
|
|
|
size_t OnSysWrite(const void *buffer, size_t size);
|
2003-09-26 20:07:22 +00:00
|
|
|
off_t OnSysTell() const { return m_pos; }
|
|
|
|
|
|
|
|
virtual void DoFlush(bool final);
|
1998-07-24 17:13:47 +00:00
|
|
|
|
|
|
|
protected:
|
1998-07-14 12:06:50 +00:00
|
|
|
size_t m_z_size;
|
|
|
|
unsigned char *m_z_buffer;
|
1998-09-17 17:30:13 +00:00
|
|
|
struct z_stream_s *m_deflate;
|
2003-09-26 20:07:22 +00:00
|
|
|
off_t m_pos;
|
2003-01-02 23:38:11 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxZlibOutputStream)
|
1998-07-14 12:06:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1999-06-15 20:21:59 +00:00
|
|
|
// wxUSE_ZLIB && wxUSE_STREAMS
|
1999-01-04 13:52:06 +00:00
|
|
|
|
|
|
|
#endif
|
1999-07-09 15:30:31 +00:00
|
|
|
// _WX_WXZSTREAM_H__
|
|
|
|
|