68 Buffer (
const void* b, uint32 size);
74 Buffer (uint32 size, uint8 initVal);
113 bool grow (uint32 memSize);
116 void fillup (uint8 initVal = 0);
122 bool isFull ()
const {
return (fillSize == memSize); }
123 uint32
getFree ()
const {
return (memSize - fillSize); }
126 void shiftAt (uint32 position, int32 amount);
127 void move (int32 amount, uint8 initVal = 0);
129 bool copy (uint32 from, uint32 to, uint32 bytes);
130 uint32
get (
void* b, uint32 size);
137 bool put (
const void* , uint32 size);
138 bool put (
void* , uint32 size);
139 bool put (uint8* , uint32 size);
140 bool put (char8* , uint32 size);
141 bool put (
const uint8* , uint32 size);
142 bool put (
const char8* , uint32 size);
145 void set (uint8 value);
148 bool appendString (
const tchar* s);
149 bool appendString (tchar* s);
150 bool appendString (tchar c) {
return put (c); }
152 bool appendString8 (
const char8* s);
153 bool appendString16 (
const char16* s);
155 bool appendString8 (char8* s) {
return appendString8 ((
const char8*)s); }
156 bool appendString8 (
unsigned char* s) {
return appendString8 ((
const char8*)s); }
157 bool appendString8 (
const unsigned char* s) {
return appendString8 ((
const char8*)s); }
159 bool appendString8 (char8 c) {
return put ((uint8)c); }
160 bool appendString8 (
unsigned char c) {
return put (c); }
161 bool appendString16 (char16 c) {
return put (c); }
162 bool appendString16 (char16* s) {
return appendString16 ((
const char16*)s); }
164 bool prependString (
const tchar* s);
165 bool prependString (tchar* s);
166 bool prependString (tchar c);
168 bool prependString8 (
const char8* s);
169 bool prependString16 (
const char16* s);
171 bool prependString8 (char8 c);
172 bool prependString8 (
unsigned char c) {
return prependString8 ((char8)c); }
173 bool prependString8 (char8* s) {
return prependString8 ((
const char8*)s); }
174 bool prependString8 (
unsigned char* s) {
return prependString8((
const char8*)s); }
175 bool prependString8 (
const unsigned char* s) {
return prependString8 ((
const char8*)s); }
176 bool prependString16 (char16 c);
177 bool prependString16 (char16* s) {
return prependString16 ((
const char16*)s); }
179 bool operator+= (
const char* s) {
return appendString8 (s); }
180 bool operator+= (
char c) {
return appendString8 (c); }
181 bool operator+= (
const char16* s) {
return appendString16 (s); }
182 bool operator+= (char16 c) {
return appendString16 (c); }
184 bool operator= (
const char* s) {
flush ();
return appendString8 (s); }
185 bool operator= (
const char16* s) {
flush ();
return appendString16 (s); }
187 bool operator= (char16 c) {
flush ();
return appendString16 (c); }
189 void endString () {
put (tchar (0));}
190 void endString8 () {
put (char8 (0));}
191 void endString16 () {
put (char16 (0));}
193 bool makeHexString (String& result);
194 bool fromHexString (
const char8*
string);
197 operator void* ()
const {
return (
void*)buffer; }
198 inline tchar*
str ()
const {
return (tchar*)buffer;}
199 inline char8*
str8 ()
const {
return (char8*)buffer;}
200 inline char16*
str16 ()
const {
return (char16*)buffer;}
201 inline int8*
int8Ptr ()
const {
return (int8*)buffer;}
202 inline uint8*
uint8Ptr ()
const {
return (uint8*)buffer; }
203 inline int16*
int16Ptr ()
const {
return (int16*)buffer; }
204 inline uint16*
uint16Ptr ()
const {
return (uint16*)buffer; }
205 inline int32*
int32Ptr ()
const {
return (int32*)buffer; }
206 inline uint32*
uint32Ptr ()
const {
return (uint32*)buffer; }
207 inline float*
floatPtr ()
const {
return (
float*)buffer; }
208 inline double*
doublePtr ()
const {
return (
double*)buffer; }
209 inline char16*
wcharPtr ()
const {
return (char16*)buffer;}
213 int32 operator ! () {
return buffer ==
nullptr; }
221 bool swap (int16 swapSize);
222 static bool swap (
void* buffer, uint32 bufferSize, int16 swapSize);
241 static const uint32 defaultDelta = 0x1000;
249inline bool Buffer::put (
void* p, uint32 count) {
return put ((
const void*)p , count ); }
250inline bool Buffer::put (uint8 * p, uint32 count) {
return put ((
const void*)p , count ); }
251inline bool Buffer::put (char8* p, uint32 count) {
return put ((
const void*)p , count ); }
252inline bool Buffer::put (
const uint8* p, uint32 count) {
return put ((
const void*)p , count ); }
253inline bool Buffer::put (
const char8* p, uint32 count) {
return put ((
const void*)p , count ); }
256inline bool Buffer::appendString (
const tchar* s)
259 return appendString16 (s);
261 return appendString8 (s);
266inline bool Buffer::appendString (tchar* s)
269 return appendString16 (s);
271 return appendString8 (s);
276inline bool Buffer::prependString (
const tchar* s)
279 return prependString16 (s);
281 return prependString8 (s);
286inline bool Buffer::prependString (tchar* s)
289 return prependString16 (s);
291 return prependString8 (s);
296inline bool Buffer::prependString (tchar c)
299 return prependString16 (c);
301 return prependString8 (c);
void take(Buffer &from)
takes another Buffer's memory, frees the current Buffer's memory
void shiftStart(int32 amount)
moves all memory by given amount, grows the Buffer if necessary
uint16 * uint16Ptr() const
conversion
void flush()
sets fill size to zero
int8 * int8Ptr() const
conversion
bool put(uint8)
append value at end, grows Buffer if necessary
void operator=(const Buffer &buff)
Assignment operator - copies contents from a given Buffer and increases the size if necessary.
bool truncateToFillSize()
virtual bool toWideString(int32 sourceCodePage)
Converts a Buffer's content to UTF-16 from a given multi-byte code page, Buffer must contain char8 of...
bool setFillSize(uint32 c)
sets a new fill size, does not change any memory
void move(int32 amount, uint8 initVal=0)
shifts memory at start without growing the buffer, so data is lost and initialized with init val
void setDelta(uint32 d)
define the block size by which the Buffer grows, see grow()
float * floatPtr() const
conversion
void fillup(uint8 initVal=0)
set from fillSize to end
virtual bool toMultibyteString(int32 destCodePage)
Converts a Buffer's content from UTF-16 to a given multi-byte code page, Buffer must contain UTF-16 e...
bool copy(uint32 from, uint32 to, uint32 bytes)
copies a number of bytes from one position to another, the size may be adapted
tchar * str() const
conversion
char16 * str16() const
conversion
int16 * int16Ptr() const
conversion
bool operator==(const Buffer &buff) const
Comparison operator - copies contents from a given Buffer and increases the size if necessary.
uint32 get(void *b, uint32 size)
copy to buffer from fillSize, and shift fillSize
uint32 getFillSize() const
char16 * wcharPtr() const
conversion
uint8 * uint8Ptr() const
conversion
Buffer()
Default constructor, allocates no memory at all.
bool setMaxSize(uint32 size)
see grow()
char8 * str8() const
conversion
int32 * int32Ptr() const
conversion
virtual ~Buffer()
Destructor - deallocates the internal memory.
bool setSize(uint32 newSize)
Sets a new size for this Buffer, keeping as much content as possible.
uint32 * uint32Ptr() const
conversion
double * doublePtr() const
conversion
bool grow(uint32 memSize)
Increases the Buffer to the next block, block size given by delta.
int8 * operator+(uint32 i)
int8 * pass()
pass the current Buffer's memory
void shiftAt(uint32 position, int32 amount)
moves memory starting at the given position
bool swap(int16 swapSize)
swap all bytes of this Buffer by the given swapSize