]> git.saurik.com Git - wxWidgets.git/blobdiff - interface/wx/mstream.h
Add test for absence of events from wxSpinCtrlDouble ctor.
[wxWidgets.git] / interface / wx / mstream.h
index c6c2eacd6cb032cb6f08af0e3d64ceeecadfff84..be70e4faf941aa8da46fc8a49ee89a9b483c6bb7 100644 (file)
@@ -1,15 +1,33 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        mstream.h
-// Purpose:     interface of wxMemoryOutputStream
+// Purpose:     interface of wxMemoryOutputStream, wxMemoryInputStream
 // Author:      wxWidgets team
-// RCS-ID:      $Id$
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 /**
     @class wxMemoryOutputStream
 
-    @todo describe me.
+    This class allows to use all methods taking a wxOutputStream reference to write
+    to in-memory data.
+
+    Example:
+    @code
+        wxMemoryOutputStream stream;
+        if (!my_wxImage.SaveFile(stream))
+            return;
+
+        // now we can access the saved image bytes:
+        wxStreamBuffer* theBuffer = stream.GetOutputStreamBuffer();
+        unsigned char byte;
+        if (theBuffer->Read(byte, 1) != 1)
+            return;
+
+        // ... do something with 'byte'...
+
+        // remember that ~wxMemoryOutputStream will destroy the internal
+        // buffer since we didn't provide our own when constructing it
+    @endcode
 
     @library{wxbase}
     @category{streams}
@@ -24,12 +42,15 @@ public:
         grow if required.
 
         @warning
-        If the buffer is created, it will be destroyed at the destruction of the stream.
+        If the buffer is created by wxMemoryOutputStream, it will be destroyed
+        at the destruction of the stream.
     */
     wxMemoryOutputStream(void* data = NULL, size_t length = 0);
 
     /**
         Destructor.
+
+        If the buffer wasn't provided by the user, it will be deleted here.
     */
     virtual ~wxMemoryOutputStream();
 
@@ -41,7 +62,7 @@ public:
 
     /**
         Returns the pointer to the stream object used as an internal buffer
-        for that stream.
+        for this stream.
     */
     wxStreamBuffer* GetOutputStreamBuffer() const;
 };
@@ -51,7 +72,23 @@ public:
 /**
     @class wxMemoryInputStream
 
-    @todo describe me.
+    This class allows to use all methods taking a wxInputStream reference to read
+    in-memory data.
+
+    Example:
+    @code
+        // we've got a block of memory containing a BMP image and we want
+        // to use wxImage to load it:
+        wxMemoryInputStream stream(my_memory_block, size);
+
+        wxImage theBitmap;
+        if (!theBitmap.LoadFile(stream, wxBITMAP_TYPE_BMP))
+            return;
+
+        // we can now safely delete the original memory buffer as the data
+        // has been decoded by wxImage:
+        delete [] my_memory_block;
+    @endcode
 
     @library{wxbase}
     @category{streams}
@@ -66,7 +103,7 @@ public:
         buffer data of length len. The stream does not take ownership of the buffer,
         i.e. the buffer will not be deleted in its destructor.
     */
-    wxMemoryInputStream(const char* data, size_t len);
+    wxMemoryInputStream(const void* data, size_t len);
 
     /**
         Creates a new read-only memory stream, initializing it with the data from
@@ -79,14 +116,14 @@ public:
         data from the given input stream @a stream.
 
         The @a len argument specifies the amount of data to read from the
-        @a stream. Setting it to @e wxInvalidOffset means that the @a stream
+        @a stream. Setting it to ::wxInvalidOffset means that the @a stream
         is to be read entirely (i.e. till the EOF is reached).
     */
     wxMemoryInputStream(wxInputStream& stream,
                         wxFileOffset len = wxInvalidOffset);
 
     /**
-        Destructor.
+        Destructor. Does NOT free the buffer provided in the ctor.
     */
     virtual ~wxMemoryInputStream();