]> git.saurik.com Git - wxWidgets.git/blame - interface/buffer.h
replace @b Note with @note; replace '' with "
[wxWidgets.git] / interface / 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
9/**
10 @class wxMemoryBuffer
11 @wxheader{buffer.h}
7c913512 12
23324ae1 13 A @b wxMemoryBuffer is a useful data structure for storing arbitrary sized
8024723d
FM
14 blocks of memory. wxMemoryBuffer guarantees deletion of the memory block when
15 the object is destroyed.
7c913512 16
23324ae1 17 @library{wxbase}
8024723d 18 @category{data}
23324ae1 19*/
7c913512 20class wxMemoryBuffer
23324ae1
FM
21{
22public:
8024723d
FM
23 /**
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
26 copies made from it.
27
28 @see @ref overview_refcount
29 */
30 wxMemoryBuffer(const wxMemoryBuffer& src);
31
23324ae1
FM
32 /**
33 Create a new buffer.
8024723d 34
7c913512 35 @param size
8024723d 36 size of the new buffer.
23324ae1 37 */
7c913512 38 wxMemoryBuffer(size_t size);
23324ae1
FM
39
40 /**
41 Append a single byte to the buffer.
8024723d 42
7c913512 43 @param data
4cc4bfaf 44 New byte to append to the buffer.
23324ae1
FM
45 */
46 void AppendByte(char data);
47
48 /**
49 Ensure that the buffer is big enough and return a pointer to the start
7c913512 50 of the empty space in the buffer. This pointer can be used to directly
8024723d
FM
51 write data into the buffer, this new data will be appended to the
52 existing data.
53
7c913512 54 @param sizeNeeded
4cc4bfaf
FM
55 Amount of extra space required in the buffer for
56 the append operation
23324ae1 57 */
4cc4bfaf 58 void* GetAppendBuf(size_t sizeNeeded);
23324ae1
FM
59
60 /**
61 Returns the size of the buffer.
62 */
d2aa927a 63 size_t GetBufSize() const;
23324ae1
FM
64
65 /**
66 Return a pointer to the data in the buffer.
67 */
d2aa927a 68 void* GetData() const;
23324ae1
FM
69
70 /**
71 Returns the length of the valid data in the buffer.
72 */
d2aa927a 73 size_t GetDataLen() const;
23324ae1
FM
74
75 /**
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
4cc4bfaf 78 up to @a sizeNeeded bytes.
23324ae1 79 */
4cc4bfaf 80 void* GetWriteBuf(size_t sizeNeeded);
23324ae1
FM
81
82 /**
4cc4bfaf 83 Ensures the buffer has at least @a size bytes available.
23324ae1
FM
84 */
85 void SetBufSize(size_t size);
86
87 /**
8024723d
FM
88 Sets the length of the data stored in the buffer.
89 Mainly useful for truncating existing data.
90
7c913512 91 @param size
4cc4bfaf
FM
92 New length of the valid data in the buffer. This is
93 distinct from the allocated size
23324ae1
FM
94 */
95 void SetDataLen(size_t size);
96
97 /**
98 Update the length after completing a direct append, which
99 you must have used GetAppendBuf() to initialise.
8024723d 100
7c913512 101 @param sizeUsed
4cc4bfaf
FM
102 This is the amount of new data that has been
103 appended.
23324ae1
FM
104 */
105 void UngetAppendBuf(size_t sizeUsed);
106
107 /**
108 Update the buffer after completing a direct write, which
109 you must have used GetWriteBuf() to initialise.
8024723d 110
7c913512 111 @param sizeUsed
4cc4bfaf
FM
112 The amount of data written in to buffer
113 by the direct write
23324ae1
FM
114 */
115 void UngetWriteBuf(size_t sizeUsed);
116};
e54c96f1 117