]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/buffer.h
Removing more CodeWarrior project files.
[wxWidgets.git] / interface / wx / buffer.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: buffer.h
e54c96f1 3// Purpose: interface of wxMemoryBuffer
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
8ef2a553
FM
9
10/**
11 wxCharTypeBuffer<T> is a template class for storing characters.
12
13 @todo provide better docs for this class
14
3c99e2fd
FM
15 @tparam T
16 The type of the characters stored in this class.
17
8ef2a553 18 @nolibrary
3c99e2fd 19 @category{data}
8ef2a553
FM
20*/
21template <typename T>
22class wxCharTypeBuffer
23{
24public:
25 typedef T CharType;
26
27 wxCharTypeBuffer(const CharType *str = NULL);
28 wxCharTypeBuffer(size_t len);
29 wxCharTypeBuffer(const wxCharTypeBuffer& src);
30 ~wxCharTypeBuffer();
31
32 void reset();
33
34 wxCharTypeBuffer& operator=(const CharType *str);
35 wxCharTypeBuffer& operator=(const wxCharTypeBuffer& src);
36
37 bool extend(size_t len);
38
39 CharType *data();
40 const CharType *data() const;
41 operator const CharType *() const;
42 CharType operator[](size_t n) const;
43};
44
45/**
46 This is a specialization of wxCharTypeBuffer<T> for @c char type.
47
48 @todo provide better docs for this class
49
50 @nolibrary
3c99e2fd 51 @category{data}
8ef2a553
FM
52*/
53class wxCharBuffer : public wxCharTypeBuffer<char>
54{
55public:
56 typedef wxCharTypeBuffer<char> wxCharTypeBufferBase;
57
58 wxCharBuffer(const wxCharTypeBufferBase& buf);
59 wxCharBuffer(const CharType *str = NULL);
60 wxCharBuffer(size_t len);
61 wxCharBuffer(const wxCStrData& cstr);
62};
63
64/**
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>
67
68 @nolibrary
3c99e2fd 69 @category{data}
8ef2a553
FM
70*/
71class wxWCharBuffer : public wxCharTypeBuffer<wchar_t>
72{
73public:
74 typedef wxCharTypeBuffer<wchar_t> wxCharTypeBufferBase;
75
76 wxWCharBuffer(const wxCharTypeBufferBase& buf);
77 wxWCharBuffer(const CharType *str = NULL);
78 wxWCharBuffer(size_t len);
79 wxWCharBuffer(const wxCStrData& cstr);
80};
81
23324ae1
FM
82/**
83 @class wxMemoryBuffer
7c913512 84
23324ae1 85 A @b wxMemoryBuffer is a useful data structure for storing arbitrary sized
8024723d
FM
86 blocks of memory. wxMemoryBuffer guarantees deletion of the memory block when
87 the object is destroyed.
7c913512 88
23324ae1 89 @library{wxbase}
8024723d 90 @category{data}
23324ae1 91*/
7c913512 92class wxMemoryBuffer
23324ae1
FM
93{
94public:
8024723d
FM
95 /**
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
98 copies made from it.
99
100 @see @ref overview_refcount
101 */
102 wxMemoryBuffer(const wxMemoryBuffer& src);
103
23324ae1
FM
104 /**
105 Create a new buffer.
8024723d 106
7c913512 107 @param size
8024723d 108 size of the new buffer.
23324ae1 109 */
0a98423e 110 wxMemoryBuffer(size_t size = DefBufSize);
23324ae1
FM
111
112 /**
113 Append a single byte to the buffer.
8024723d 114
7c913512 115 @param data
4cc4bfaf 116 New byte to append to the buffer.
23324ae1
FM
117 */
118 void AppendByte(char data);
119
120 /**
121 Ensure that the buffer is big enough and return a pointer to the start
7c913512 122 of the empty space in the buffer. This pointer can be used to directly
8024723d
FM
123 write data into the buffer, this new data will be appended to the
124 existing data.
125
7c913512 126 @param sizeNeeded
4cc4bfaf
FM
127 Amount of extra space required in the buffer for
128 the append operation
23324ae1 129 */
4cc4bfaf 130 void* GetAppendBuf(size_t sizeNeeded);
23324ae1
FM
131
132 /**
133 Returns the size of the buffer.
134 */
d2aa927a 135 size_t GetBufSize() const;
23324ae1
FM
136
137 /**
138 Return a pointer to the data in the buffer.
139 */
d2aa927a 140 void* GetData() const;
23324ae1
FM
141
142 /**
143 Returns the length of the valid data in the buffer.
144 */
d2aa927a 145 size_t GetDataLen() const;
23324ae1
FM
146
147 /**
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
4cc4bfaf 150 up to @a sizeNeeded bytes.
23324ae1 151 */
4cc4bfaf 152 void* GetWriteBuf(size_t sizeNeeded);
23324ae1
FM
153
154 /**
4cc4bfaf 155 Ensures the buffer has at least @a size bytes available.
23324ae1
FM
156 */
157 void SetBufSize(size_t size);
158
159 /**
8024723d
FM
160 Sets the length of the data stored in the buffer.
161 Mainly useful for truncating existing data.
162
7c913512 163 @param size
4cc4bfaf
FM
164 New length of the valid data in the buffer. This is
165 distinct from the allocated size
23324ae1
FM
166 */
167 void SetDataLen(size_t size);
168
169 /**
170 Update the length after completing a direct append, which
171 you must have used GetAppendBuf() to initialise.
8024723d 172
7c913512 173 @param sizeUsed
4cc4bfaf
FM
174 This is the amount of new data that has been
175 appended.
23324ae1
FM
176 */
177 void UngetAppendBuf(size_t sizeUsed);
178
179 /**
180 Update the buffer after completing a direct write, which
181 you must have used GetWriteBuf() to initialise.
8024723d 182
7c913512 183 @param sizeUsed
4cc4bfaf
FM
184 The amount of data written in to buffer
185 by the direct write
23324ae1
FM
186 */
187 void UngetWriteBuf(size_t sizeUsed);
188};
e54c96f1 189