]>
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 /////////////////////////////////////////////////////////////////////////////
11 wxCharTypeBuffer<T> is a template class for storing characters.
13 @todo provide better docs for this class
16 The type of the characters stored in this class.
22 class wxCharTypeBuffer
27 wxCharTypeBuffer(const CharType
*str
= NULL
);
28 wxCharTypeBuffer(size_t len
);
29 wxCharTypeBuffer(const wxCharTypeBuffer
& src
);
34 wxCharTypeBuffer
& operator=(const CharType
*str
);
35 wxCharTypeBuffer
& operator=(const wxCharTypeBuffer
& src
);
37 bool extend(size_t len
);
40 const CharType
*data() const;
41 operator const CharType
*() const;
42 CharType
operator[](size_t n
) const;
46 This is a specialization of wxCharTypeBuffer<T> for @c char type.
48 @todo provide better docs for this class
53 class wxCharBuffer
: public wxCharTypeBuffer
<char>
56 typedef wxCharTypeBuffer
<char> wxCharTypeBufferBase
;
58 wxCharBuffer(const wxCharTypeBufferBase
& buf
);
59 wxCharBuffer(const CharType
*str
= NULL
);
60 wxCharBuffer(size_t len
);
61 wxCharBuffer(const wxCStrData
& cstr
);
65 This is a specialization of wxCharTypeBuffer<T> for @c wchar_t type.
66 This class is available only when <tt>wxUSE_WCHAR_T==1</tt>
71 class wxWCharBuffer
: public wxCharTypeBuffer
<wchar_t>
74 typedef wxCharTypeBuffer
<wchar_t> wxCharTypeBufferBase
;
76 wxWCharBuffer(const wxCharTypeBufferBase
& buf
);
77 wxWCharBuffer(const CharType
*str
= NULL
);
78 wxWCharBuffer(size_t len
);
79 wxWCharBuffer(const wxCStrData
& cstr
);
85 A @b wxMemoryBuffer is a useful data structure for storing arbitrary sized
86 blocks of memory. wxMemoryBuffer guarantees deletion of the memory block when
87 the object is destroyed.
96 Copy constructor, refcounting is used for performance, but wxMemoryBuffer
97 is not a copy-on-write structure so changes made to one buffer effect all
100 @see @ref overview_refcount
102 wxMemoryBuffer(const wxMemoryBuffer
& src
);
108 size of the new buffer.
110 wxMemoryBuffer(size_t size
= DefBufSize
);
113 Append a single byte to the buffer.
116 New byte to append to the buffer.
118 void AppendByte(char data
);
121 Ensure that the buffer is big enough and return a pointer to the start
122 of the empty space in the buffer. This pointer can be used to directly
123 write data into the buffer, this new data will be appended to the
127 Amount of extra space required in the buffer for
130 void* GetAppendBuf(size_t sizeNeeded
);
133 Returns the size of the buffer.
135 size_t GetBufSize() const;
138 Return a pointer to the data in the buffer.
140 void* GetData() const;
143 Returns the length of the valid data in the buffer.
145 size_t GetDataLen() const;
148 Ensure the buffer is big enough and return a pointer to the
149 buffer which can be used to directly write into the buffer
150 up to @a sizeNeeded bytes.
152 void* GetWriteBuf(size_t sizeNeeded
);
155 Ensures the buffer has at least @a size bytes available.
157 void SetBufSize(size_t size
);
160 Sets the length of the data stored in the buffer.
161 Mainly useful for truncating existing data.
164 New length of the valid data in the buffer. This is
165 distinct from the allocated size
167 void SetDataLen(size_t size
);
170 Update the length after completing a direct append, which
171 you must have used GetAppendBuf() to initialise.
174 This is the amount of new data that has been
177 void UngetAppendBuf(size_t sizeUsed
);
180 Update the buffer after completing a direct write, which
181 you must have used GetWriteBuf() to initialise.
184 The amount of data written in to buffer
187 void UngetWriteBuf(size_t sizeUsed
);