]>
git.saurik.com Git - wxWidgets.git/blob - interface/buffer.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: interface of wxMemoryBuffer
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
13 A @b wxMemoryBuffer is a useful data structure for storing arbitrary sized
14 blocks of memory. wxMemoryBuffer guarantees deletion of the memory block when
15 the object is destroyed.
24 Copy constructor, refcounting is used for performance, but wxMemoryBuffer
25 is not a copy-on-write structure so changes made to one buffer effect all
28 @see @ref overview_refcount
30 wxMemoryBuffer(const wxMemoryBuffer
& src
);
36 size of the new buffer.
38 wxMemoryBuffer(size_t size
);
41 Append a single byte to the buffer.
44 New byte to append to the buffer.
46 void AppendByte(char data
);
49 Ensure that the buffer is big enough and return a pointer to the start
50 of the empty space in the buffer. This pointer can be used to directly
51 write data into the buffer, this new data will be appended to the
55 Amount of extra space required in the buffer for
58 void* GetAppendBuf(size_t sizeNeeded
);
61 Returns the size of the buffer.
63 size_t GetBufSize() const;
66 Return a pointer to the data in the buffer.
68 void* GetData() const;
71 Returns the length of the valid data in the buffer.
73 size_t GetDataLen() const;
76 Ensure the buffer is big enough and return a pointer to the
77 buffer which can be used to directly write into the buffer
78 up to @a sizeNeeded bytes.
80 void* GetWriteBuf(size_t sizeNeeded
);
83 Ensures the buffer has at least @a size bytes available.
85 void SetBufSize(size_t size
);
88 Sets the length of the data stored in the buffer.
89 Mainly useful for truncating existing data.
92 New length of the valid data in the buffer. This is
93 distinct from the allocated size
95 void SetDataLen(size_t size
);
98 Update the length after completing a direct append, which
99 you must have used GetAppendBuf() to initialise.
102 This is the amount of new data that has been
105 void UngetAppendBuf(size_t sizeUsed
);
108 Update the buffer after completing a direct write, which
109 you must have used GetWriteBuf() to initialise.
112 The amount of data written in to buffer
115 void UngetWriteBuf(size_t sizeUsed
);