LMMS
Loading...
Searching...
No Matches
Steinberg::Buffer Class Reference

#include <fbuffer.h>

Public Types

enum  swapSize { kSwap16 = 2 , kSwap32 = 4 , kSwap64 = 8 }

Public Member Functions

 Buffer ()
 Buffer (const void *b, uint32 size)
 Buffer (uint32 size, uint8 initVal)
 Buffer (uint32 size)
 Buffer (const Buffer &buff)
virtual ~Buffer ()
void operator= (const Buffer &buff)
bool operator== (const Buffer &buff) const
uint32 getSize () const
bool setSize (uint32 newSize)
bool grow (uint32 memSize)
bool setMaxSize (uint32 size)
 see grow()
void fillup (uint8 initVal=0)
 set from fillSize to end
uint32 getFillSize () const
bool setFillSize (uint32 c)
 sets a new fill size, does not change any memory
void flush ()
 sets fill size to zero
bool truncateToFillSize ()
bool isFull () const
uint32 getFree () const
void shiftStart (int32 amount)
 moves all memory by given amount, grows the Buffer if necessary
void shiftAt (uint32 position, int32 amount)
 moves memory starting at the given position
void move (int32 amount, uint8 initVal=0)
 shifts memory at start without growing the buffer, so data is lost and initialized with init val
bool copy (uint32 from, uint32 to, uint32 bytes)
 copies a number of bytes from one position to another, the size may be adapted
uint32 get (void *b, uint32 size)
 copy to buffer from fillSize, and shift fillSize
void setDelta (uint32 d)
 define the block size by which the Buffer grows, see grow()
bool put (uint8)
 append value at end, grows Buffer if necessary
bool put (char16 c)
 append value at end, grows Buffer if necessary
bool put (char c)
 append value at end, grows Buffer if necessary
bool put (const void *, uint32 size)
 append bytes from a given buffer, grows Buffer if necessary
bool put (void *, uint32 size)
 append bytes from a given buffer, grows Buffer if necessary
bool put (uint8 *, uint32 size)
 append bytes from a given buffer, grows Buffer if necessary
bool put (char8 *, uint32 size)
 append bytes from a given buffer, grows Buffer if necessary
bool put (const uint8 *, uint32 size)
 append bytes from a given buffer, grows Buffer if necessary
bool put (const char8 *, uint32 size)
 append bytes from a given buffer, grows Buffer if necessary
bool put (const String &)
 append String at end, grows Buffer if necessary
void set (uint8 value)
 fills complete Buffer with given value
bool appendString (const tchar *s)
bool appendString (tchar *s)
bool appendString (tchar 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 tchar *s)
bool prependString (tchar *s)
bool prependString (tchar 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
tcharstr () const
 conversion
char8str8 () const
 conversion
char16str16 () const
 conversion
int8int8Ptr () const
 conversion
uint8uint8Ptr () const
 conversion
int16int16Ptr () const
 conversion
uint16uint16Ptr () const
 conversion
int32int32Ptr () const
 conversion
uint32uint32Ptr () const
 conversion
float * floatPtr () const
 conversion
double * doublePtr () const
 conversion
char16wcharPtr () const
 conversion
int8operator+ (uint32 i)
int32 operator! ()
bool swap (int16 swapSize)
 swap all bytes of this Buffer by the given swapSize
void take (Buffer &from)
 takes another Buffer's memory, frees the current Buffer's memory
int8pass ()
 pass the current Buffer's memory
virtual bool toWideString (int32 sourceCodePage)
virtual bool toMultibyteString (int32 destCodePage)

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

Protected Attributes

int8buffer
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

Enumerator
kSwap16 
kSwap32 
kSwap64 

Constructor & Destructor Documentation

◆ Buffer() [1/5]

Steinberg::Buffer::Buffer ( )

Default constructor, allocates no memory at all.

◆ Buffer() [2/5]

Steinberg::Buffer::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]

Steinberg::Buffer::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]

Steinberg::Buffer::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]

Steinberg::Buffer::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()

Steinberg::Buffer::~Buffer ( )
virtual

Destructor - deallocates the internal memory.

Member Function Documentation

◆ appendString() [1/3]

bool Steinberg::Buffer::appendString ( const tchar * s)
inline

◆ appendString() [2/3]

bool Steinberg::Buffer::appendString ( tchar * s)
inline

◆ appendString() [3/3]

bool Steinberg::Buffer::appendString ( tchar c)
inline

◆ appendString16() [1/3]

bool Steinberg::Buffer::appendString16 ( char16 * s)
inline

◆ appendString16() [2/3]

bool Steinberg::Buffer::appendString16 ( char16 c)
inline

◆ appendString16() [3/3]

bool Steinberg::Buffer::appendString16 ( const char16 * s)

◆ appendString8() [1/6]

bool Steinberg::Buffer::appendString8 ( char8 * s)
inline

◆ appendString8() [2/6]

bool Steinberg::Buffer::appendString8 ( char8 c)
inline

◆ appendString8() [3/6]

bool Steinberg::Buffer::appendString8 ( const char8 * s)

◆ appendString8() [4/6]

bool Steinberg::Buffer::appendString8 ( const unsigned char * s)
inline

◆ appendString8() [5/6]

bool Steinberg::Buffer::appendString8 ( unsigned char * s)
inline

◆ appendString8() [6/6]

bool Steinberg::Buffer::appendString8 ( unsigned char c)
inline

◆ copy()

bool Steinberg::Buffer::copy ( uint32 from,
uint32 to,
uint32 bytes )

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

◆ doublePtr()

double * Steinberg::Buffer::doublePtr ( ) const
inline

conversion

◆ endString()

void Steinberg::Buffer::endString ( )
inline

◆ endString16()

void Steinberg::Buffer::endString16 ( )
inline

◆ endString8()

void Steinberg::Buffer::endString8 ( )
inline

◆ fillup()

void Steinberg::Buffer::fillup ( uint8 initVal = 0)

set from fillSize to end

◆ floatPtr()

float * Steinberg::Buffer::floatPtr ( ) const
inline

conversion

◆ flush()

void Steinberg::Buffer::flush ( )
inline

sets fill size to zero

◆ fromHexString()

bool Steinberg::Buffer::fromHexString ( const char8 * string)

◆ get()

uint32 Steinberg::Buffer::get ( void * b,
uint32 size )

copy to buffer from fillSize, and shift fillSize

◆ getFillSize()

uint32 Steinberg::Buffer::getFillSize ( ) const
inline
Returns
the actual fill size

◆ getFree()

uint32 Steinberg::Buffer::getFree ( ) const
inline
Returns
remaining memory

◆ getSize()

uint32 Steinberg::Buffer::getSize ( ) const
inline
Returns
the actual size of the Buffer's memory, in bytes.

◆ grow()

bool Steinberg::Buffer::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

◆ int16Ptr()

int16 * Steinberg::Buffer::int16Ptr ( ) const
inline

conversion

◆ int32Ptr()

int32 * Steinberg::Buffer::int32Ptr ( ) const
inline

conversion

◆ int8Ptr()

int8 * Steinberg::Buffer::int8Ptr ( ) const
inline

conversion

◆ isFull()

bool Steinberg::Buffer::isFull ( ) const
inline
Returns
true, if all memory is filled up, else false

◆ makeHexString()

bool Steinberg::Buffer::makeHexString ( String & result)

◆ move()

void Steinberg::Buffer::move ( int32 amount,
uint8 initVal = 0 )

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

◆ operator void *()

Steinberg::Buffer::operator void * ( ) const
inline

conversion

◆ operator!()

int32 Steinberg::Buffer::operator! ( )
inline

◆ operator+()

int8 * Steinberg::Buffer::operator+ ( uint32 i)
Returns
the internal Buffer's address plus the given offset i, zero if offset is out of range

◆ operator+=() [1/4]

bool Steinberg::Buffer::operator+= ( char c)
inline

◆ operator+=() [2/4]

bool Steinberg::Buffer::operator+= ( char16 c)
inline

◆ operator+=() [3/4]

bool Steinberg::Buffer::operator+= ( const char * s)
inline

◆ operator+=() [4/4]

bool Steinberg::Buffer::operator+= ( const char16 * s)
inline

◆ operator=() [1/5]

bool Steinberg::Buffer::operator= ( char16 c)
inline

◆ operator=() [2/5]

bool Steinberg::Buffer::operator= ( char8 c)
inline

◆ operator=() [3/5]

void Steinberg::Buffer::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=() [4/5]

bool Steinberg::Buffer::operator= ( const char * s)
inline

◆ operator=() [5/5]

bool Steinberg::Buffer::operator= ( const char16 * s)
inline

◆ operator==()

bool Steinberg::Buffer::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

◆ pass()

int8 * Steinberg::Buffer::pass ( )

pass the current Buffer's memory

◆ prependString() [1/3]

bool Steinberg::Buffer::prependString ( const tchar * s)
inline

◆ prependString() [2/3]

bool Steinberg::Buffer::prependString ( tchar * s)
inline

◆ prependString() [3/3]

bool Steinberg::Buffer::prependString ( tchar c)
inline

◆ prependString16() [1/3]

bool Steinberg::Buffer::prependString16 ( char16 * s)
inline

◆ prependString16() [2/3]

bool Steinberg::Buffer::prependString16 ( char16 c)

◆ prependString16() [3/3]

bool Steinberg::Buffer::prependString16 ( const char16 * s)

◆ prependString8() [1/6]

bool Steinberg::Buffer::prependString8 ( char8 * s)
inline

◆ prependString8() [2/6]

bool Steinberg::Buffer::prependString8 ( char8 c)

◆ prependString8() [3/6]

bool Steinberg::Buffer::prependString8 ( const char8 * s)

◆ prependString8() [4/6]

bool Steinberg::Buffer::prependString8 ( const unsigned char * s)
inline

◆ prependString8() [5/6]

bool Steinberg::Buffer::prependString8 ( unsigned char * s)
inline

◆ prependString8() [6/6]

bool Steinberg::Buffer::prependString8 ( unsigned char c)
inline

◆ put() [1/10]

bool Steinberg::Buffer::put ( char c)

append value at end, grows Buffer if necessary

◆ put() [2/10]

bool Steinberg::Buffer::put ( char16 c)

append value at end, grows Buffer if necessary

◆ put() [3/10]

bool Steinberg::Buffer::put ( char8 * p,
uint32 size )
inline

append bytes from a given buffer, grows Buffer if necessary

◆ put() [4/10]

bool Steinberg::Buffer::put ( const char8 * p,
uint32 size )
inline

append bytes from a given buffer, grows Buffer if necessary

◆ put() [5/10]

bool Steinberg::Buffer::put ( const String & str)

append String at end, grows Buffer if necessary

◆ put() [6/10]

bool Steinberg::Buffer::put ( const uint8 * p,
uint32 size )
inline

append bytes from a given buffer, grows Buffer if necessary

◆ put() [7/10]

bool Steinberg::Buffer::put ( const void * toPut,
uint32 size )

append bytes from a given buffer, grows Buffer if necessary

◆ put() [8/10]

bool Steinberg::Buffer::put ( uint8 * p,
uint32 size )
inline

append bytes from a given buffer, grows Buffer if necessary

◆ put() [9/10]

bool Steinberg::Buffer::put ( uint8 byte)

append value at end, grows Buffer if necessary

◆ put() [10/10]

bool Steinberg::Buffer::put ( void * p,
uint32 size )
inline

append bytes from a given buffer, grows Buffer if necessary

◆ set()

void Steinberg::Buffer::set ( uint8 value)

fills complete Buffer with given value

◆ setDelta()

void Steinberg::Buffer::setDelta ( uint32 d)
inline

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

◆ setFillSize()

bool Steinberg::Buffer::setFillSize ( uint32 c)

sets a new fill size, does not change any memory

◆ setMaxSize()

bool Steinberg::Buffer::setMaxSize ( uint32 size)
inline

see grow()

◆ setSize()

bool Steinberg::Buffer::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

◆ shiftAt()

void Steinberg::Buffer::shiftAt ( uint32 position,
int32 amount )

moves memory starting at the given position

◆ shiftStart()

void Steinberg::Buffer::shiftStart ( int32 amount)
inline

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

◆ str()

tchar * Steinberg::Buffer::str ( ) const
inline

conversion

◆ str16()

char16 * Steinberg::Buffer::str16 ( ) const
inline

conversion

◆ str8()

char8 * Steinberg::Buffer::str8 ( ) const
inline

conversion

◆ swap() [1/2]

bool Steinberg::Buffer::swap ( int16 swapSize)

swap all bytes of this Buffer by the given swapSize

◆ swap() [2/2]

bool Steinberg::Buffer::swap ( void * buffer,
uint32 bufferSize,
int16 swapSize )
static

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

◆ take()

void Steinberg::Buffer::take ( Buffer & from)

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

◆ toMultibyteString()

bool Steinberg::Buffer::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

◆ toWideString()

bool Steinberg::Buffer::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

◆ truncateToFillSize()

bool Steinberg::Buffer::truncateToFillSize ( )
Returns
always true, truncates the size of the Buffer to the actual fill size

◆ uint16Ptr()

uint16 * Steinberg::Buffer::uint16Ptr ( ) const
inline

conversion

◆ uint32Ptr()

uint32 * Steinberg::Buffer::uint32Ptr ( ) const
inline

conversion

◆ uint8Ptr()

uint8 * Steinberg::Buffer::uint8Ptr ( ) const
inline

conversion

◆ wcharPtr()

char16 * Steinberg::Buffer::wcharPtr ( ) const
inline

conversion

Member Data Documentation

◆ buffer

int8* Steinberg::Buffer::buffer
protected

◆ defaultDelta

const uint32 Steinberg::Buffer::defaultDelta = 0x1000
staticprotected

◆ delta

uint32 Steinberg::Buffer::delta
protected

◆ fillSize

uint32 Steinberg::Buffer::fillSize
protected

◆ memSize

uint32 Steinberg::Buffer::memSize
protected

The documentation for this class was generated from the following files: