]> git.saurik.com Git - wxWidgets.git/blobdiff - interface/wx/mstream.h
Don't send event from wxMSW::wxListCtrl::DeleteAllItems() if it did nothing.
[wxWidgets.git] / interface / wx / mstream.h
index 37319f10b2b7a5229e462b4933da29d7bc6dc413..0dc691e42a5e37326e32a38b4634c77c1973ceaf 100644 (file)
@@ -1,15 +1,34 @@
 /////////////////////////////////////////////////////////////////////////////
 // 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
-    @wxheader{mstream.h}
 
+    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}
@@ -22,24 +41,29 @@ public:
     /**
         If @a data is @NULL, then it will initialize a new empty buffer which will
         grow if required.
+
+        @warning
+        If the buffer is created by wxMemoryOutputStream, it will be destroyed
+        at the destruction of the stream.
     */
-    wxMemoryOutputStream(char* data = NULL, size_t length = 0);
+    wxMemoryOutputStream(void* data = NULL, size_t length = 0);
 
     /**
         Destructor.
+
+        If the buffer wasn't provided by the user, it will be deleted here.
     */
-    ~wxMemoryOutputStream();
+    virtual ~wxMemoryOutputStream();
 
     /**
-        CopyTo allowed you to transfer data from the internal buffer of
-        wxMemoryOutputStream to an external buffer. @a len specifies the size of
-        the buffer.
+        Allows you to transfer data from the internal buffer of wxMemoryOutputStream
+        to an external buffer. @a len specifies the size of the buffer.
     */
-    size_t CopyTo(char* buffer, size_t len) const;
+    size_t CopyTo(void* buffer, size_t len) const;
 
     /**
         Returns the pointer to the stream object used as an internal buffer
-        for that stream.
+        for this stream.
     */
     wxStreamBuffer* GetOutputStreamBuffer() const;
 };
@@ -48,8 +72,24 @@ public:
 
 /**
     @class wxMemoryInputStream
-    @wxheader{mstream.h}
 
+    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}
@@ -59,24 +99,34 @@ public:
 class wxMemoryInputStream : public wxInputStream
 {
 public:
-    //@{
     /**
-        Creates a new read-only memory stream, initializing it with the
-        data from the given input stream @e stream.
-        The @a len argument specifies the amount of data to read from
-        the @e stream. Setting it to @e wxInvalidOffset means that
-        the @a stream is to be read entirely (i.e. till the EOF is reached).
+        Initializes a new read-only memory stream which will use the specified
+        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 void* data, size_t len);
+
+    /**
+        Creates a new read-only memory stream, initializing it with the data from
+        the given output stream @a stream.
     */
-    wxMemoryInputStream(const char* data, size_t len);
     wxMemoryInputStream(const wxMemoryOutputStream& stream);
+
+    /**
+        Creates a new read-only memory stream, initializing it with the
+        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 ::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.
     */
-    ~wxMemoryInputStream();
+    virtual ~wxMemoryInputStream();
 
     /**
         Returns the pointer to the stream object used as an internal buffer