]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/buffer.h
504df2aeb68905656d83a59fc7cb0a30a5f10e76
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
19 class wxCharTypeBuffer
24 wxCharTypeBuffer(const CharType
*str
= NULL
);
25 wxCharTypeBuffer(size_t len
);
26 wxCharTypeBuffer(const wxCharTypeBuffer
& src
);
31 wxCharTypeBuffer
& operator=(const CharType
*str
);
32 wxCharTypeBuffer
& operator=(const wxCharTypeBuffer
& src
);
34 bool extend(size_t len
);
37 const CharType
*data() const;
38 operator const CharType
*() const;
39 CharType
operator[](size_t n
) const;
43 This is a specialization of wxCharTypeBuffer<T> for @c char type.
45 @todo provide better docs for this class
50 class wxCharBuffer
: public wxCharTypeBuffer
<char>
53 typedef wxCharTypeBuffer
<char> wxCharTypeBufferBase
;
55 wxCharBuffer(const wxCharTypeBufferBase
& buf
);
56 wxCharBuffer(const CharType
*str
= NULL
);
57 wxCharBuffer(size_t len
);
58 wxCharBuffer(const wxCStrData
& cstr
);
62 This is a specialization of wxCharTypeBuffer<T> for @c wchar_t type.
63 This class is available only when <tt>wxUSE_WCHAR_T==1</tt>
68 class wxWCharBuffer
: public wxCharTypeBuffer
<wchar_t>
71 typedef wxCharTypeBuffer
<wchar_t> wxCharTypeBufferBase
;
73 wxWCharBuffer(const wxCharTypeBufferBase
& buf
);
74 wxWCharBuffer(const CharType
*str
= NULL
);
75 wxWCharBuffer(size_t len
);
76 wxWCharBuffer(const wxCStrData
& cstr
);
84 A @b wxMemoryBuffer is a useful data structure for storing arbitrary sized
85 blocks of memory. wxMemoryBuffer guarantees deletion of the memory block when
86 the object is destroyed.
95 Copy constructor, refcounting is used for performance, but wxMemoryBuffer
96 is not a copy-on-write structure so changes made to one buffer effect all
99 @see @ref overview_refcount
101 wxMemoryBuffer(const wxMemoryBuffer
& src
);
107 size of the new buffer.
109 wxMemoryBuffer(size_t size
= DefBufSize
);
112 Append a single byte to the buffer.
115 New byte to append to the buffer.
117 void AppendByte(char data
);
120 Ensure that the buffer is big enough and return a pointer to the start
121 of the empty space in the buffer. This pointer can be used to directly
122 write data into the buffer, this new data will be appended to the
126 Amount of extra space required in the buffer for
129 void* GetAppendBuf(size_t sizeNeeded
);
132 Returns the size of the buffer.
134 size_t GetBufSize() const;
137 Return a pointer to the data in the buffer.
139 void* GetData() const;
142 Returns the length of the valid data in the buffer.
144 size_t GetDataLen() const;
147 Ensure the buffer is big enough and return a pointer to the
148 buffer which can be used to directly write into the buffer
149 up to @a sizeNeeded bytes.
151 void* GetWriteBuf(size_t sizeNeeded
);
154 Ensures the buffer has at least @a size bytes available.
156 void SetBufSize(size_t size
);
159 Sets the length of the data stored in the buffer.
160 Mainly useful for truncating existing data.
163 New length of the valid data in the buffer. This is
164 distinct from the allocated size
166 void SetDataLen(size_t size
);
169 Update the length after completing a direct append, which
170 you must have used GetAppendBuf() to initialise.
173 This is the amount of new data that has been
176 void UngetAppendBuf(size_t sizeUsed
);
179 Update the buffer after completing a direct write, which
180 you must have used GetWriteBuf() to initialise.
183 The amount of data written in to buffer
186 void UngetWriteBuf(size_t sizeUsed
);