]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/mstream.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxMemoryOutputStream, wxMemoryInputStream
4 // Author: wxWidgets team
5 // Licence: wxWindows licence
6 /////////////////////////////////////////////////////////////////////////////
9 @class wxMemoryOutputStream
11 This class allows to use all methods taking a wxOutputStream reference to write
16 wxMemoryOutputStream stream;
17 if (!my_wxImage.SaveFile(stream))
20 // now we can access the saved image bytes:
21 wxStreamBuffer* theBuffer = stream.GetOutputStreamBuffer();
23 if (theBuffer->Read(byte, 1) != 1)
26 // ... do something with 'byte'...
28 // remember that ~wxMemoryOutputStream will destroy the internal
29 // buffer since we didn't provide our own when constructing it
37 class wxMemoryOutputStream
: public wxOutputStream
41 If @a data is @NULL, then it will initialize a new empty buffer which will
45 If the buffer is created by wxMemoryOutputStream, it will be destroyed
46 at the destruction of the stream.
48 wxMemoryOutputStream(void* data
= NULL
, size_t length
= 0);
53 If the buffer wasn't provided by the user, it will be deleted here.
55 virtual ~wxMemoryOutputStream();
58 Allows you to transfer data from the internal buffer of wxMemoryOutputStream
59 to an external buffer. @a len specifies the size of the buffer.
61 size_t CopyTo(void* buffer
, size_t len
) const;
64 Returns the pointer to the stream object used as an internal buffer
67 wxStreamBuffer
* GetOutputStreamBuffer() const;
73 @class wxMemoryInputStream
75 This class allows to use all methods taking a wxInputStream reference to read
80 // we've got a block of memory containing a BMP image and we want
81 // to use wxImage to load it:
82 wxMemoryInputStream stream(my_memory_block, size);
85 if (!theBitmap.LoadFile(stream, wxBITMAP_TYPE_BMP))
88 // we can now safely delete the original memory buffer as the data
89 // has been decoded by wxImage:
90 delete [] my_memory_block;
96 @see wxStreamBuffer, wxMemoryOutputStream
98 class wxMemoryInputStream
: public wxInputStream
102 Initializes a new read-only memory stream which will use the specified
103 buffer data of length len. The stream does not take ownership of the buffer,
104 i.e. the buffer will not be deleted in its destructor.
106 wxMemoryInputStream(const void* data
, size_t len
);
109 Creates a new read-only memory stream, initializing it with the data from
110 the given output stream @a stream.
112 wxMemoryInputStream(const wxMemoryOutputStream
& stream
);
115 Creates a new read-only memory stream, initializing it with the
116 data from the given input stream @a stream.
118 The @a len argument specifies the amount of data to read from the
119 @a stream. Setting it to ::wxInvalidOffset means that the @a stream
120 is to be read entirely (i.e. till the EOF is reached).
122 wxMemoryInputStream(wxInputStream
& stream
,
123 wxFileOffset len
= wxInvalidOffset
);
126 Destructor. Does NOT free the buffer provided in the ctor.
128 virtual ~wxMemoryInputStream();
131 Returns the pointer to the stream object used as an internal buffer
134 wxStreamBuffer
* GetInputStreamBuffer() const;