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