]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/mstream.h
Add documentation of emitted events to wxScrolled documentation.
[wxWidgets.git] / interface / wx / mstream.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: mstream.h
31de2596 3// Purpose: interface of wxMemoryOutputStream, wxMemoryInputStream
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
526954c5 6// Licence: wxWindows licence
23324ae1
FM
7/////////////////////////////////////////////////////////////////////////////
8
9/**
10 @class wxMemoryOutputStream
7c913512 11
31de2596
FM
12 This class allows to use all methods taking a wxOutputStream reference to write
13 to in-memory data.
14
15 Example:
16 @code
17 wxMemoryOutputStream stream;
18 if (!my_wxImage.SaveFile(stream))
19 return;
20
21 // now we can access the saved image bytes:
22 wxStreamBuffer* theBuffer = stream.GetOutputStreamBuffer();
23 unsigned char byte;
24 if (theBuffer->Read(byte, 1) != 1)
25 return;
26
27 // ... do something with 'byte'...
28
29 // remember that ~wxMemoryOutputStream will destroy the internal
30 // buffer since we didn't provide our own when constructing it
31 @endcode
7c913512 32
23324ae1
FM
33 @library{wxbase}
34 @category{streams}
7c913512 35
e54c96f1 36 @see wxStreamBuffer
23324ae1
FM
37*/
38class wxMemoryOutputStream : public wxOutputStream
39{
40public:
41 /**
4cc4bfaf 42 If @a data is @NULL, then it will initialize a new empty buffer which will
23324ae1 43 grow if required.
ba1d7a6c
FM
44
45 @warning
31de2596
FM
46 If the buffer is created by wxMemoryOutputStream, it will be destroyed
47 at the destruction of the stream.
23324ae1 48 */
8067ee11 49 wxMemoryOutputStream(void* data = NULL, size_t length = 0);
23324ae1
FM
50
51 /**
52 Destructor.
31de2596
FM
53
54 If the buffer wasn't provided by the user, it will be deleted here.
23324ae1 55 */
adaaa686 56 virtual ~wxMemoryOutputStream();
23324ae1
FM
57
58 /**
ba1d7a6c
FM
59 Allows you to transfer data from the internal buffer of wxMemoryOutputStream
60 to an external buffer. @a len specifies the size of the buffer.
23324ae1 61 */
5267aefd 62 size_t CopyTo(void* buffer, size_t len) const;
23324ae1
FM
63
64 /**
65 Returns the pointer to the stream object used as an internal buffer
31de2596 66 for this stream.
23324ae1 67 */
328f5751 68 wxStreamBuffer* GetOutputStreamBuffer() const;
23324ae1
FM
69};
70
71
e54c96f1 72
23324ae1
FM
73/**
74 @class wxMemoryInputStream
7c913512 75
31de2596
FM
76 This class allows to use all methods taking a wxInputStream reference to read
77 in-memory data.
78
79 Example:
80 @code
81 // we've got a block of memory containing a BMP image and we want
82 // to use wxImage to load it:
83 wxMemoryInputStream stream(my_memory_block, size);
84
85 wxImage theBitmap;
86 if (!theBitmap.LoadFile(stream, wxBITMAP_TYPE_BMP))
87 return;
88
89 // we can now safely delete the original memory buffer as the data
90 // has been decoded by wxImage:
91 delete [] my_memory_block;
92 @endcode
7c913512 93
23324ae1
FM
94 @library{wxbase}
95 @category{streams}
7c913512 96
e54c96f1 97 @see wxStreamBuffer, wxMemoryOutputStream
23324ae1
FM
98*/
99class wxMemoryInputStream : public wxInputStream
100{
101public:
23324ae1 102 /**
ba1d7a6c
FM
103 Initializes a new read-only memory stream which will use the specified
104 buffer data of length len. The stream does not take ownership of the buffer,
105 i.e. the buffer will not be deleted in its destructor.
23324ae1 106 */
0a98423e 107 wxMemoryInputStream(const void* data, size_t len);
ba1d7a6c
FM
108
109 /**
110 Creates a new read-only memory stream, initializing it with the data from
111 the given output stream @a stream.
112 */
7c913512 113 wxMemoryInputStream(const wxMemoryOutputStream& stream);
ba1d7a6c
FM
114
115 /**
116 Creates a new read-only memory stream, initializing it with the
117 data from the given input stream @a stream.
118
119 The @a len argument specifies the amount of data to read from the
acdad9db 120 @a stream. Setting it to ::wxInvalidOffset means that the @a stream
ba1d7a6c
FM
121 is to be read entirely (i.e. till the EOF is reached).
122 */
7c913512
FM
123 wxMemoryInputStream(wxInputStream& stream,
124 wxFileOffset len = wxInvalidOffset);
23324ae1
FM
125
126 /**
31de2596 127 Destructor. Does NOT free the buffer provided in the ctor.
23324ae1 128 */
adaaa686 129 virtual ~wxMemoryInputStream();
23324ae1
FM
130
131 /**
132 Returns the pointer to the stream object used as an internal buffer
133 for that stream.
134 */
328f5751 135 wxStreamBuffer* GetInputStreamBuffer() const;
23324ae1 136};
e54c96f1 137