]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/buffer.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxMemoryBuffer
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 A @b wxMemoryBuffer is a useful data structure for storing arbitrary sized
13 blocks of memory. wxMemoryBuffer guarantees deletion of the memory block when
14 the object is destroyed.
23 Copy constructor, refcounting is used for performance, but wxMemoryBuffer
24 is not a copy-on-write structure so changes made to one buffer effect all
27 @see @ref overview_refcount
29 wxMemoryBuffer(const wxMemoryBuffer
& src
);
35 size of the new buffer.
37 wxMemoryBuffer(size_t size
);
40 Append a single byte to the buffer.
43 New byte to append to the buffer.
45 void AppendByte(char data
);
48 Ensure that the buffer is big enough and return a pointer to the start
49 of the empty space in the buffer. This pointer can be used to directly
50 write data into the buffer, this new data will be appended to the
54 Amount of extra space required in the buffer for
57 void* GetAppendBuf(size_t sizeNeeded
);
60 Returns the size of the buffer.
62 size_t GetBufSize() const;
65 Return a pointer to the data in the buffer.
67 void* GetData() const;
70 Returns the length of the valid data in the buffer.
72 size_t GetDataLen() const;
75 Ensure the buffer is big enough and return a pointer to the
76 buffer which can be used to directly write into the buffer
77 up to @a sizeNeeded bytes.
79 void* GetWriteBuf(size_t sizeNeeded
);
82 Ensures the buffer has at least @a size bytes available.
84 void SetBufSize(size_t size
);
87 Sets the length of the data stored in the buffer.
88 Mainly useful for truncating existing data.
91 New length of the valid data in the buffer. This is
92 distinct from the allocated size
94 void SetDataLen(size_t size
);
97 Update the length after completing a direct append, which
98 you must have used GetAppendBuf() to initialise.
101 This is the amount of new data that has been
104 void UngetAppendBuf(size_t sizeUsed
);
107 Update the buffer after completing a direct write, which
108 you must have used GetWriteBuf() to initialise.
111 The amount of data written in to buffer
114 void UngetWriteBuf(size_t sizeUsed
);