Base Module VST 3.7 SDK for developing VST plug-in

Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
Buffer Class Reference

Buffer. More...

`#include <fbuffer.h>`

## Public Types
enum | swapSize { kSwap16 = 2 , kSwap32 = 4 , kSwap64 = 8 }

## Public Member Functions
| Buffer ()
| Default constructor, allocates no memory at all. More...
| Buffer (const void *b, uint32 size)
| Constructor - creates a new Buffer with a given size and copies contents from optional memory pointer. More...
| Buffer (uint32 size, uint8 initVal)
| Constructor - creates a new Buffer with a given size and fills it all with a given value. More...
| Buffer (uint32 size)
| Constructor - creates a new Buffer with a given size. More...
| Buffer (const Buffer &buff)
| Copy constructor - creates a new Buffer from a given Buffer. More...
virtual | ~Buffer ()
| Destructor - deallocates the internal memory. More...
void | operator= (const Buffer &buff)
| Assignment operator - copies contents from a given Buffer and increases the size if necessary. More...
bool | operator== (const Buffer &buff) const
| Comparison operator - copies contents from a given Buffer and increases the size if necessary. More...
uint32 | getSize () const
bool | setSize (uint32 newSize)
| Sets a new size for this Buffer, keeping as much content as possible. More...
bool | grow (uint32 memSize)
| Increases the Buffer to the next block, block size given by delta. More...
bool | setMaxSize (uint32 size)
| see grow() More...
void | fillup (uint8 initVal=0)
| set from fillSize to end More...
uint32 | getFillSize () const
bool | setFillSize (uint32 c)
| sets a new fill size, does not change any memory More...
void | flush ()
| sets fill size to zero More...
bool | truncateToFillSize ()
bool | isFull () const
uint32 | getFree () const
void | shiftStart (int32 amount)
| moves all memory by given amount, grows the Buffer if necessary More...
void | shiftAt (uint32 position, int32 amount)
| moves memory starting at the given position More...
void | move (int32 amount, uint8 initVal=0)
| shifts memory at start without growing the buffer, so data is lost and initialized with init val More...
bool | copy (uint32 from, uint32 to, uint32 bytes)
| copies a number of bytes from one position to another, the size may be adapted More...
uint32 | get (void *b, uint32 size)
| copy to buffer from fillSize, and shift fillSize More...
void | setDelta (uint32 d)
| define the block size by which the Buffer grows, see grow() More...
bool | put (uint8)
| append value at end, grows Buffer if necessary More...
bool | put (char16 c)
| append value at end, grows Buffer if necessary More...
bool | put (char c)
| append value at end, grows Buffer if necessary More...
bool | put (const void *, uint32 size)
| append bytes from a given buffer, grows Buffer if necessary More...
bool | put (void *, uint32 size)
| append bytes from a given buffer, grows Buffer if necessary More...
bool | put (uint8 *, uint32 size)
| append bytes from a given buffer, grows Buffer if necessary More...
bool | put (char8 *, uint32 size)
| append bytes from a given buffer, grows Buffer if necessary More...
bool | put (const uint8 *, uint32 size)
| append bytes from a given buffer, grows Buffer if necessary More...
bool | put (const char8 *, uint32 size)
| append bytes from a given buffer, grows Buffer if necessary More...
bool | put (const String &)
| append String at end, grows Buffer if necessary More...
void | set (uint8 value)
| fills complete Buffer with given value More...
bool | appendString (const char *s)
bool | appendString (char *s)
bool | appendString (char c)
bool | appendString8 (const char8 *s)
bool | appendString16 (const char16 *s)
bool | appendString8 (char8 *s)
bool | appendString8 (unsigned char *s)
bool | appendString8 (const unsigned char *s)
bool | appendString8 (char8 c)
bool | appendString8 (unsigned char c)
bool | appendString16 (char16 c)
bool | appendString16 (char16 *s)
bool | prependString (const char *s)
bool | prependString (char *s)
bool | prependString (char c)
bool | prependString8 (const char8 *s)
bool | prependString16 (const char16 *s)
bool | prependString8 (char8 c)
bool | prependString8 (unsigned char c)
bool | prependString8 (char8 *s)
bool | prependString8 (unsigned char *s)
bool | prependString8 (const unsigned char *s)
bool | prependString16 (char16 c)
bool | prependString16 (char16 *s)
bool | operator+= (const char *s)
bool | operator+= (char c)
bool | operator+= (const char16 *s)
bool | operator+= (char16 c)
bool | operator= (const char *s)
bool | operator= (const char16 *s)
bool | operator= (char8 c)
bool | operator= (char16 c)
void | endString ()
void | endString8 ()
void | endString16 ()
bool | makeHexString (String &result)
bool | fromHexString (const char8 *string)
| operator void * () const
| conversion More...
char * | str () const
| conversion More...
char8 * | str8 () const
| conversion More...
char16 * | str16 () const
| conversion More...
int8 * | int8Ptr () const
| conversion More...
uint8 * | uint8Ptr () const
| conversion More...
int16 * | int16Ptr () const
| conversion More...
uint16 * | uint16Ptr () const
| conversion More...
int32 * | int32Ptr () const
| conversion More...
uint32 * | uint32Ptr () const
| conversion More...
float * | floatPtr () const
| conversion More...
double * | doublePtr () const
| conversion More...
char16 * | wcharPtr () const
| conversion More...
int8 * | operator+ (uint32 i)
int32 | operator! ()
bool | swap (int16 swapSize)
| swap all bytes of this Buffer by the given swapSize More...
void | take (Buffer &from)
| takes another Buffer's memory, frees the current Buffer's memory More...
int8 * | pass ()
| pass the current Buffer's memory More...
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 given encoding. More...
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 encoded characters. More...

## Static Public Member Functions
static bool | swap (void *buffer, uint32 bufferSize, int16 swapSize)
| utility, swap given number of bytes in given buffer by the given swapSize More...

## Protected Attributes
int8 * | buffer
uint32 | memSize
uint32 | fillSize
uint32 | delta

## Static Protected Attributes
static const uint32 | defaultDelta = 0x1000

## Detailed Description

Buffer.

A Buffer is an object-oriented wrapper for a piece of memory. It adds several utility functions, e.g. for managing the size of the Buffer, appending or prepending values or strings to it. Internally it uses the standard memory functions malloc(), free(), etc.

## Member Enumeration Documentation

## ◆ swapSize

enum swapSize

Enumerator
kSwap16 |
kSwap32 |
kSwap64 |

## Constructor & Destructor Documentation

## ◆ Buffer() [1/5]

Buffer | ( |  | ) |

Default constructor, allocates no memory at all.

## ◆ Buffer() [2/5]

Buffer | ( | const void * | b,
|  | uint32 | size
| ) |  |

Constructor - creates a new Buffer with a given size and copies contents from optional memory pointer.

Parameters

  [in] | b | : optional memory pointer with the size of at least the given size
  [in] | size | : the size of the new Buffer to be allocated, in bytes.

## ◆ Buffer() [3/5]

Buffer | ( | uint32 | size,
|  | uint8 | initVal
| ) |  |

Constructor - creates a new Buffer with a given size and fills it all with a given value.

Parameters

  [in] | size | : the size of the new Buffer to be allocated, in bytes.
  [in] | initVal | : the initial value the Buffer will be completely filled with

## ◆ Buffer() [4/5]

Buffer | ( | uint32 | size | ) |

Constructor - creates a new Buffer with a given size.

Parameters

  [in] | size | : the size of the new Buffer to be allocated, in bytes.

## ◆ Buffer() [5/5]

Buffer | ( | const Buffer & | buff | ) |

Copy constructor - creates a new Buffer from a given Buffer.

Parameters

  [in] | buff | : the Buffer from which all memory will be copied to the new one

## ◆ ~Buffer()

~Buffer | ( |  | ) |
| virtual

Destructor - deallocates the internal memory.

## Member Function Documentation

## ◆ operator=() [1/5]

void operator= | ( | const Buffer & | buff | ) |

Assignment operator - copies contents from a given Buffer and increases the size if necessary.

Parameters

  [in] | buff | : the Buffer from which all memory will be copied

## ◆ operator==()

bool operator== | ( | const Buffer & | buff | ) | const

Comparison operator - copies contents from a given Buffer and increases the size if necessary.

Parameters

  [in] | buff | : the Buffer to be compared to

Returns
  true, if the given Buffer's content is equal to this one, else false

## ◆ getSize()

uint32 getSize | ( |  | ) | const
| inline

Returns
  the actual size of the Buffer's memory, in bytes.

## ◆ setSize()

bool setSize | ( | uint32 | newSize | ) |

Sets a new size for this Buffer, keeping as much content as possible.

Parameters

  [in] | newSize | : the new size for the Buffer, in bytes, newSize maybe zero

Returns
  true, if the new size could be adapted, else false

## ◆ grow()

bool grow | ( | uint32 | memSize | ) |

Increases the Buffer to the next block, block size given by delta.

Parameters

  [in] | memSize | : the new minimum size of the Buffer, newSize maybe zero

Returns
  true, if the Buffer could be grown successfully, else false

## ◆ setMaxSize()

bool setMaxSize | ( | uint32 | size | ) |
| inline

see grow()

## ◆ fillup()

void fillup | ( | uint8 | initVal = `0` | ) |

set from fillSize to end

## ◆ getFillSize()

uint32 getFillSize | ( |  | ) | const
| inline

Returns
  the actual fill size

## ◆ setFillSize()

bool setFillSize | ( | uint32 | c | ) |

sets a new fill size, does not change any memory

## ◆ flush()

void flush | ( |  | ) |
| inline

sets fill size to zero

## ◆ truncateToFillSize()

bool truncateToFillSize | ( |  | ) |

Returns
  always true, truncates the size of the Buffer to the actual fill size

## ◆ isFull()

bool isFull | ( |  | ) | const
| inline

Returns
  true, if all memory is filled up, else false

## ◆ getFree()

uint32 getFree | ( |  | ) | const
| inline

Returns
  remaining memory

## ◆ shiftStart()

void shiftStart | ( | int32 | amount | ) |
| inline

moves all memory by given amount, grows the Buffer if necessary

## ◆ shiftAt()

void shiftAt | ( | uint32 | position,
|  | int32 | amount
| ) |  |

moves memory starting at the given position

## ◆ move()

void move | ( | int32 | amount,
|  | uint8 | initVal = `0`
| ) |  |

shifts memory at start without growing the buffer, so data is lost and initialized with init val

## ◆ copy()

bool copy | ( | uint32 | from,
|  | uint32 | to,
|  | uint32 | bytes
| ) |  |

copies a number of bytes from one position to another, the size may be adapted

## ◆ get()

uint32 get | ( | void * | b,
|  | uint32 | size
| ) |  |

copy to buffer from fillSize, and shift fillSize

## ◆ setDelta()

void setDelta | ( | uint32 | d | ) |
| inline

define the block size by which the Buffer grows, see grow()

## ◆ put() [1/10]

bool put | ( | uint8 | byte | ) |

append value at end, grows Buffer if necessary

## ◆ put() [2/10]

bool put | ( | char16 | c | ) |

append value at end, grows Buffer if necessary

## ◆ put() [3/10]

bool put | ( | char | c | ) |

append value at end, grows Buffer if necessary

## ◆ put() [4/10]

bool put | ( | const void * | toPut,
|  | uint32 | size
| ) |  |

append bytes from a given buffer, grows Buffer if necessary

## ◆ put() [5/10]

bool put | ( | void * | p,
|  | uint32 | size
| ) |  |
| inline

append bytes from a given buffer, grows Buffer if necessary

## ◆ put() [6/10]

bool put | ( | uint8 * | p,
|  | uint32 | size
| ) |  |
| inline

append bytes from a given buffer, grows Buffer if necessary

## ◆ put() [7/10]

bool put | ( | char8 * | p,
|  | uint32 | size
| ) |  |
| inline

append bytes from a given buffer, grows Buffer if necessary

## ◆ put() [8/10]

bool put | ( | const uint8 * | p,
|  | uint32 | size
| ) |  |
| inline

append bytes from a given buffer, grows Buffer if necessary

## ◆ put() [9/10]

bool put | ( | const char8 * | p,
|  | uint32 | size
| ) |  |
| inline

append bytes from a given buffer, grows Buffer if necessary

## ◆ put() [10/10]

bool put | ( | const String & | str | ) |

append String at end, grows Buffer if necessary

## ◆ set()

void set | ( | uint8 | value | ) |

fills complete Buffer with given value

## ◆ appendString() [1/3]

bool appendString | ( | const char * | s | ) |
| inline

## ◆ appendString() [2/3]

bool appendString | ( | char * | s | ) |
| inline

## ◆ appendString() [3/3]

bool appendString | ( | char | c | ) |
| inline

## ◆ appendString8() [1/6]

bool appendString8 | ( | const char8 * | s | ) |

## ◆ appendString16() [1/3]

bool appendString16 | ( | const char16 * | s | ) |

## ◆ appendString8() [2/6]

bool appendString8 | ( | char8 * | s | ) |
| inline

## ◆ appendString8() [3/6]

bool appendString8 | ( | unsigned char * | s | ) |
| inline

## ◆ appendString8() [4/6]

bool appendString8 | ( | const unsigned char * | s | ) |
| inline

## ◆ appendString8() [5/6]

bool appendString8 | ( | char8 | c | ) |
| inline

## ◆ appendString8() [6/6]

bool appendString8 | ( | unsigned char | c | ) |
| inline

## ◆ appendString16() [2/3]

bool appendString16 | ( | char16 | c | ) |
| inline

## ◆ appendString16() [3/3]

bool appendString16 | ( | char16 * | s | ) |
| inline

## ◆ prependString() [1/3]

bool prependString | ( | const char * | s | ) |
| inline

## ◆ prependString() [2/3]

bool prependString | ( | char * | s | ) |
| inline

## ◆ prependString() [3/3]

bool prependString | ( | char | c | ) |
| inline

## ◆ prependString8() [1/6]

bool prependString8 | ( | const char8 * | s | ) |

## ◆ prependString16() [1/3]

bool prependString16 | ( | const char16 * | s | ) |

## ◆ prependString8() [2/6]

bool prependString8 | ( | char8 | c | ) |

## ◆ prependString8() [3/6]

bool prependString8 | ( | unsigned char | c | ) |
| inline

## ◆ prependString8() [4/6]

bool prependString8 | ( | char8 * | s | ) |
| inline

## ◆ prependString8() [5/6]

bool prependString8 | ( | unsigned char * | s | ) |
| inline

## ◆ prependString8() [6/6]

bool prependString8 | ( | const unsigned char * | s | ) |
| inline

## ◆ prependString16() [2/3]

bool prependString16 | ( | char16 | c | ) |

## ◆ prependString16() [3/3]

bool prependString16 | ( | char16 * | s | ) |
| inline

## ◆ operator+=() [1/4]

bool operator+= | ( | const char * | s | ) |
| inline

## ◆ operator+=() [2/4]

bool operator+= | ( | char | c | ) |
| inline

## ◆ operator+=() [3/4]

bool operator+= | ( | const char16 * | s | ) |
| inline

## ◆ operator+=() [4/4]

bool operator+= | ( | char16 | c | ) |
| inline

## ◆ operator=() [2/5]

bool operator= | ( | const char * | s | ) |
| inline

## ◆ operator=() [3/5]

bool operator= | ( | const char16 * | s | ) |
| inline

## ◆ operator=() [4/5]

bool operator= | ( | char8 | c | ) |
| inline

## ◆ operator=() [5/5]

bool operator= | ( | char16 | c | ) |
| inline

## ◆ endString()

void endString | ( |  | ) |
| inline

## ◆ endString8()

void endString8 | ( |  | ) |
| inline

## ◆ endString16()

void endString16 | ( |  | ) |
| inline

## ◆ makeHexString()

bool makeHexString | ( | String & | result | ) |

## ◆ fromHexString()

bool fromHexString | ( | const char8 * | string | ) |

## ◆ operator void *()

operator void * | ( |  | ) | const
| inline

conversion

## ◆ str()

char * str | ( |  | ) | const
| inline

conversion

## ◆ str8()

char8 * str8 | ( |  | ) | const
| inline

conversion

## ◆ str16()

char16 * str16 | ( |  | ) | const
| inline

conversion

## ◆ int8Ptr()

int8 * int8Ptr | ( |  | ) | const
| inline

conversion

## ◆ uint8Ptr()

uint8 * uint8Ptr | ( |  | ) | const
| inline

conversion

## ◆ int16Ptr()

int16 * int16Ptr | ( |  | ) | const
| inline

conversion

## ◆ uint16Ptr()

uint16 * uint16Ptr | ( |  | ) | const
| inline

conversion

## ◆ int32Ptr()

int32 * int32Ptr | ( |  | ) | const
| inline

conversion

## ◆ uint32Ptr()

uint32 * uint32Ptr | ( |  | ) | const
| inline

conversion

## ◆ floatPtr()

float * floatPtr | ( |  | ) | const
| inline

conversion

## ◆ doublePtr()

double * doublePtr | ( |  | ) | const
| inline

conversion

## ◆ wcharPtr()

char16 * wcharPtr | ( |  | ) | const
| inline

conversion

## ◆ operator+()

int8 * operator+ | ( | uint32 | i | ) |

Returns
  the internal Buffer's address plus the given offset i, zero if offset is out of range

## ◆ operator!()

int32 operator! | ( |  | ) |
| inline

## ◆ swap() [1/2]

bool swap | ( | int16 | swapSize | ) |

swap all bytes of this Buffer by the given swapSize

## ◆ swap() [2/2]

bool swap | ( | void * | buffer,
|  | uint32 | bufferSize,
|  | int16 | swapSize
| ) |  |
| static

utility, swap given number of bytes in given buffer by the given swapSize

## ◆ take()

void take | ( | Buffer & | from | ) |

takes another Buffer's memory, frees the current Buffer's memory

## ◆ pass()

int8 * pass | ( |  | ) |

pass the current Buffer's memory

## ◆ toWideString()

bool toWideString | ( | int32 | sourceCodePage | ) |
| virtual

Converts a Buffer's content to UTF-16 from a given multi-byte code page, Buffer must contain char8 of given encoding.

Parameters

  [in] | sourceCodePage | : the actual code page of the Buffer's content

Returns
  true, if the conversion was successful, else false

## ◆ toMultibyteString()

bool toMultibyteString | ( | int32 | destCodePage | ) |
| virtual

Converts a Buffer's content from UTF-16 to a given multi-byte code page, Buffer must contain UTF-16 encoded characters.

Parameters

  [in] | destCodePage | : the desired code page to convert the Buffer's content to

Returns
  true, if the conversion was successful, else false

## Member Data Documentation

## ◆ defaultDelta

const uint32 defaultDelta = 0x1000
| static protected

## ◆ buffer

int8* buffer
| protected

## ◆ memSize

uint32 memSize
| protected

## ◆ fillSize

uint32 fillSize
| protected

## ◆ delta

uint32 delta
| protected

Empty

Copyright © Steinberg Media Technologies GmbH. All Rights Reserved. This documentation is under this license.