iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
IByteChunk Class Reference

Manages a block of memory, for plug-in settings store/recall. More...

#include <IPlugStructs.h>

Inheritance diagram for IByteChunk:
[legend]

Public Member Functions

int PutBytes (const void *pSrc, int nBytesToCopy)
 Copies data into the chunk, placing it at the end, resizing if necessary. More...
 
int GetBytes (void *pDst, int nBytesToCopy, int startPos) const
 Copy raw bytes from the IByteChunk, returning the new position for subsequent calls. More...
 
template<class T >
int Put (const T *pVal)
 Copies arbitary typed data into the IByteChunk. More...
 
template<class T >
int Get (T *pDst, int startPos) const
 Get arbitary typed data from the IByteChunk. More...
 
int PutStr (const char *str)
 Put a string into the IByteChunk. More...
 
int GetStr (WDL_String &str, int startPos) const
 Get a string from the IByteChunk. More...
 
int PutChunk (const IByteChunk *pRHS)
 Put another IByteChunk into this one. More...
 
void Clear ()
 Clears the chunk (resizes to 0) More...
 
int Size () const
 Returns the current size of the chunk. More...
 
int Resize (int newSize)
 Resizes the chunk. More...
 
uint8_t * GetData ()
 Gets a ptr to the chunk data. More...
 
const uint8_t * GetData () const
 Gets a const ptr to the chunk data. More...
 
bool IsEqual (IByteChunk &otherChunk) const
 Compares the size & values of the data of another chunk with this one. More...
 

Static Public Member Functions

static void InitChunkWithIPlugVer (IByteChunk &chunk)
 This method is used in order to place the IPlug version number in the chunk when serialising data. More...
 
static int GetIPlugVerFromChunk (const IByteChunk &chunk, int &position)
 Helper method to retrieve the IPlug version number from the beginning of the byte chunk. More...
 

Detailed Description

Manages a block of memory, for plug-in settings store/recall.

Definition at line 111 of file IPlugStructs.h.

Constructor & Destructor Documentation

◆ IByteChunk()

IByteChunk::IByteChunk ( )
inline

Definition at line 114 of file IPlugStructs.h.

◆ ~IByteChunk()

IByteChunk::~IByteChunk ( )
inline

Definition at line 115 of file IPlugStructs.h.

Member Function Documentation

◆ Clear()

void IByteChunk::Clear ( )
inline

Clears the chunk (resizes to 0)

Definition at line 214 of file IPlugStructs.h.

Referenced by IPluginBase::CopyPreset(), InitChunkWithIPlugVer(), IPluginBase::ModifyCurrentPreset(), and IPluginBase::UnserializePresets().

◆ Get()

template<class T >
int IByteChunk::Get ( T *  pDst,
int  startPos 
) const
inline

Get arbitary typed data from the IByteChunk.

Template Parameters
TThe type of data to be extracted
Parameters
pDstPtr to the destination where the data will be extracted
startPosThe starting position in bytes in the chunk
Returns
int The end position in the chunk (in bytes) after the copy, or -1 if the copy would have copied more data than in the chunk

Definition at line 181 of file IPlugStructs.h.

References GetBytes().

Referenced by IByteChunkReader::Get(), GetIPlugVerFromChunk(), IPluginBase::LoadBankFromFXB(), IPluginBase::LoadPresetFromFXP(), IPluginBase::SaveBankAsFXB(), IGEditorDelegate::UnserializeEditorSize(), IPluginBase::UnserializeParams(), and IPluginBase::UnserializePresets().

◆ GetBytes()

int IByteChunk::GetBytes ( void *  pDst,
int  nBytesToCopy,
int  startPos 
) const
inline

Copy raw bytes from the IByteChunk, returning the new position for subsequent calls.

Parameters
pDstThe destination buffer
nBytesToCopyThe number of bytes to copy from the chunk
startPosThe starting position in bytes in the chunk
Returns
int The end position in the chunk (in bytes) after the copy, or -1 if the copy would have copied more data than in the chunk

Definition at line 160 of file IPlugStructs.h.

References IByteGetter::GetBytes(), and Size().

Referenced by Get(), IByteChunkReader::GetBytes(), IPluginBase::LoadBankFromFXB(), and IPluginBase::LoadPresetFromFXP().

◆ GetData() [1/2]

uint8_t * IByteChunk::GetData ( )
inline

◆ GetData() [2/2]

const uint8_t * IByteChunk::GetData ( ) const
inline

Gets a const ptr to the chunk data.

Returns
const uint8_t* const Ptr to the chunk data

Definition at line 249 of file IPlugStructs.h.

◆ GetIPlugVerFromChunk()

static int IByteChunk::GetIPlugVerFromChunk ( const IByteChunk chunk,
int &  position 
)
inlinestatic

Helper method to retrieve the IPlug version number from the beginning of the byte chunk.

Parameters
chunkThe incoming byte chunk that contains the version number
positionThe position (in bytes) to start looking
Returns
The IPlug version number, retrieved from the chunk, or 0 if it failed

Definition at line 132 of file IPlugStructs.h.

References Get().

Referenced by IPluginBase::LoadBankFromFXB(), and IPluginBase::LoadPresetFromFXP().

◆ GetStr()

int IByteChunk::GetStr ( WDL_String &  str,
int  startPos 
) const
inline

Get a string from the IByteChunk.

Parameters
strWDL_String to fill
startPosThe starting position in bytes in the chunk
Returns
int The end position in the chunk (in bytes) after the copy, or -1 if the copy would have copied more data than in the chunk

Definition at line 200 of file IPlugStructs.h.

References IByteGetter::GetStr(), and Size().

Referenced by IByteChunkReader::GetStr(), and IPluginBase::UnserializePresets().

◆ InitChunkWithIPlugVer()

static void IByteChunk::InitChunkWithIPlugVer ( IByteChunk chunk)
inlinestatic

This method is used in order to place the IPlug version number in the chunk when serialising data.

In theory this is for backwards compatibility.

Parameters
chunkreference to the chunk where the version number will be placed

Definition at line 119 of file IPlugStructs.h.

References Clear(), and Put().

Referenced by IPluginBase::SaveBankAsFXB(), and IPluginBase::SavePresetAsFXP().

◆ IsEqual()

bool IByteChunk::IsEqual ( IByteChunk otherChunk) const
inline

Compares the size & values of the data of another chunk with this one.

Parameters
otherChunkThe chunk to compare with
Returns
true if the chunks are equal

Definition at line 257 of file IPlugStructs.h.

References Size().

◆ Put()

template<class T >
int IByteChunk::Put ( const T *  pVal)
inline

Copies arbitary typed data into the IByteChunk.

Template Parameters
TThe type of data to be stored
Parameters
pValPtr to the data to be stored
Returns
int The size of the chunk after insertion

Definition at line 170 of file IPlugStructs.h.

References PutBytes().

Referenced by InitChunkWithIPlugVer(), IPluginBase::MakePreset(), PutStr(), IPluginBase::SaveBankAsFXB(), IPluginBase::SavePresetAsFXP(), IGEditorDelegate::SerializeEditorSize(), IPluginBase::SerializeParams(), and IPluginBase::SerializePresets().

◆ PutBytes()

int IByteChunk::PutBytes ( const void *  pSrc,
int  nBytesToCopy 
)
inline

Copies data into the chunk, placing it at the end, resizing if necessary.

Parameters
pSrcPointer to the data to copy
nBytesToCopyNumber of bytes to copy
Returns
int The size of the chunk after insertion

Definition at line 147 of file IPlugStructs.h.

Referenced by Put(), PutChunk(), PutStr(), IPluginBase::SaveBankAsFXB(), and IPluginBase::SavePresetAsFXP().

◆ PutChunk()

int IByteChunk::PutChunk ( const IByteChunk pRHS)
inline

Put another IByteChunk into this one.

Parameters
pRHSPtr to the IByteChunk to copy in
Returns
int The size of the chunk after insertion

Definition at line 208 of file IPlugStructs.h.

References GetData(), PutBytes(), and Size().

Referenced by IPluginBase::CopyPreset(), IPluginBase::MakePresetFromChunk(), and IPluginBase::SerializePresets().

◆ PutStr()

int IByteChunk::PutStr ( const char *  str)
inline

Put a string into the IByteChunk.

Parameters
strCString to insert into the chunk
Returns
int The size of the chunk after insertion

Definition at line 189 of file IPlugStructs.h.

References Put(), and PutBytes().

Referenced by IPluginBase::SerializePresets().

◆ Resize()

int IByteChunk::Resize ( int  newSize)
inline

Resizes the chunk.

Parameters
newSizeDesired size (in bytes)
Returns
Old size (in bytes)

Definition at line 229 of file IPlugStructs.h.

Referenced by IPluginBase::LoadBankFromFXB(), IPluginBase::LoadPresetFromFXP(), and IPluginBase::MakePresetFromBlob().

◆ Size()

int IByteChunk::Size ( ) const
inline

Returns the current size of the chunk.

Returns
Current size (in bytes)

Definition at line 221 of file IPlugStructs.h.

Referenced by IPluginBase::DumpPresetBlob(), GetBytes(), GetStr(), IsEqual(), PutChunk(), IPluginBase::SaveBankAsFXB(), and IPluginBase::SavePresetAsFXP().


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