1998-07-12 11:24:52 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-11-23 11:26:12 -05:00
|
|
|
// Name: wx/mstream.h
|
1998-07-12 11:24:52 -04:00
|
|
|
// Purpose: Memory stream classes
|
|
|
|
// Author: Guilhem Lavaux
|
|
|
|
// Modified by:
|
|
|
|
// Created: 11/07/98
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Guilhem Lavaux
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-07-12 11:24:52 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2000-09-12 11:15:44 -04:00
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_WXMMSTREAM_H__
|
|
|
|
#define _WX_WXMMSTREAM_H__
|
1998-07-12 11:24:52 -04:00
|
|
|
|
2005-03-16 11:18:31 -05:00
|
|
|
#include "wx/defs.h"
|
1998-07-12 11:24:52 -04:00
|
|
|
|
1999-06-15 16:21:59 -04:00
|
|
|
#if wxUSE_STREAMS
|
|
|
|
|
2005-03-16 11:18:31 -05:00
|
|
|
#include "wx/stream.h"
|
|
|
|
|
2005-04-02 17:37:58 -05:00
|
|
|
class WXDLLIMPEXP_BASE wxMemoryOutputStream;
|
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxMemoryInputStream : public wxInputStream
|
2000-09-12 11:15:44 -04:00
|
|
|
{
|
|
|
|
public:
|
2000-11-23 11:26:12 -05:00
|
|
|
wxMemoryInputStream(const void *data, size_t length);
|
2005-04-02 17:37:58 -05:00
|
|
|
wxMemoryInputStream(const wxMemoryOutputStream& stream);
|
2000-09-12 11:15:44 -04:00
|
|
|
virtual ~wxMemoryInputStream();
|
2004-11-10 16:10:30 -05:00
|
|
|
virtual wxFileOffset GetLength() const { return m_length; }
|
2005-02-11 07:39:03 -05:00
|
|
|
virtual bool IsSeekable() const { return true; }
|
2000-09-12 11:15:44 -04:00
|
|
|
|
|
|
|
char Peek();
|
1998-07-14 08:06:50 -04:00
|
|
|
|
2000-11-23 11:26:12 -05:00
|
|
|
wxStreamBuffer *GetInputStreamBuffer() const { return m_i_streambuf; }
|
|
|
|
|
|
|
|
// deprecated, compatibility only
|
2000-09-12 11:15:44 -04:00
|
|
|
wxStreamBuffer *InputStreamBuffer() const { return m_i_streambuf; }
|
1999-07-15 14:08:57 -04:00
|
|
|
|
2000-09-12 11:15:44 -04:00
|
|
|
protected:
|
|
|
|
wxStreamBuffer *m_i_streambuf;
|
1999-07-19 13:34:59 -04:00
|
|
|
|
2000-09-12 11:15:44 -04:00
|
|
|
size_t OnSysRead(void *buffer, size_t nbytes);
|
2004-09-26 09:18:46 -04:00
|
|
|
wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
|
|
|
|
wxFileOffset OnSysTell() const;
|
1999-07-15 14:08:57 -04:00
|
|
|
|
2000-09-12 11:15:44 -04:00
|
|
|
private:
|
|
|
|
size_t m_length;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxMemoryInputStream)
|
1998-07-12 11:24:52 -04:00
|
|
|
};
|
|
|
|
|
2003-07-01 21:59:24 -04:00
|
|
|
class WXDLLIMPEXP_BASE wxMemoryOutputStream : public wxOutputStream
|
2000-09-12 11:15:44 -04:00
|
|
|
{
|
|
|
|
public:
|
2000-11-23 11:26:12 -05:00
|
|
|
// if data is !NULL it must be allocated with malloc()
|
|
|
|
wxMemoryOutputStream(void *data = NULL, size_t length = 0);
|
2000-09-12 11:15:44 -04:00
|
|
|
virtual ~wxMemoryOutputStream();
|
2004-11-10 16:10:30 -05:00
|
|
|
virtual wxFileOffset GetLength() const { return m_o_streambuf->GetLastAccess(); }
|
2005-02-11 07:39:03 -05:00
|
|
|
virtual bool IsSeekable() const { return true; }
|
1999-07-19 13:34:59 -04:00
|
|
|
|
2000-11-23 11:26:12 -05:00
|
|
|
size_t CopyTo(void *buffer, size_t len) const;
|
1999-07-15 14:08:57 -04:00
|
|
|
|
2000-11-23 11:26:12 -05:00
|
|
|
wxStreamBuffer *GetOutputStreamBuffer() const { return m_o_streambuf; }
|
|
|
|
|
|
|
|
// deprecated, compatibility only
|
|
|
|
wxStreamBuffer *OutputStreamBuffer() const { return m_o_streambuf; }
|
1999-07-22 13:51:54 -04:00
|
|
|
|
2000-09-12 11:15:44 -04:00
|
|
|
protected:
|
|
|
|
wxStreamBuffer *m_o_streambuf;
|
1999-07-15 14:08:57 -04:00
|
|
|
|
2000-09-12 11:15:44 -04:00
|
|
|
protected:
|
|
|
|
size_t OnSysWrite(const void *buffer, size_t nbytes);
|
2004-09-26 09:18:46 -04:00
|
|
|
wxFileOffset OnSysSeek(wxFileOffset pos, wxSeekMode mode);
|
|
|
|
wxFileOffset OnSysTell() const;
|
2003-01-02 18:38:11 -05:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxMemoryOutputStream)
|
1998-07-12 11:24:52 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
1999-06-15 16:21:59 -04:00
|
|
|
// wxUSE_STREAMS
|
|
|
|
|
|
|
|
#endif
|
1999-07-09 11:30:31 -04:00
|
|
|
// _WX_WXMMSTREAM_H__
|
|
|
|
|