84using ChunkID =
char[4];
99extern const ChunkID& getChunkID (ChunkType type);
102inline bool isEqualID (
const ChunkID id1,
const ChunkID id2)
104 return memcmp (id1, id2,
sizeof (ChunkID)) == 0;
132 const Entry*
getEntry (ChunkType which)
const;
135 const Entry&
at (int32 index)
const {
return entries[index]; }
146 bool writeMetaInfo (
const char* xmlBuffer, int32 size = -1,
bool forceWriting =
false);
150 bool writeChunk (
const void* data, int32 size, ChunkType which = kComponentState);
178 int32 programIndex = 0);
199 const char* xmlBuffer =
nullptr, int32 xmlSize = -1);
201 IBStream* editStream =
nullptr,
const char* xmlBuffer =
nullptr,
211 bool readID (ChunkID
id);
212 bool writeID (
const ChunkID
id);
213 bool readEqualID (
const ChunkID
id);
214 bool readSize (TSize& size);
215 bool writeSize (TSize size);
216 bool readInt32 (int32& value);
217 bool writeInt32 (int32 value);
218 bool seekTo (TSize offset);
219 bool beginChunk (Entry& e, ChunkType which);
220 bool endChunk (Entry& e);
224 enum { kMaxEntries = 128 };
225 Entry entries[kMaxEntries];
226 int32 entryCount {0};
236 static IBStream*
open (
const char* filename,
const char* mode);
239 DECLARE_FUNKNOWN_METHODS
242 tresult PLUGIN_API
read (
void* buffer, int32 numBytes, int32* numBytesRead =
nullptr) SMTG_OVERRIDE;
243 tresult PLUGIN_API
write (
void* buffer, int32 numBytes, int32* numBytesWritten =
nullptr) SMTG_OVERRIDE;
244 tresult PLUGIN_API
seek (int64 pos, int32 mode, int64* result =
nullptr) SMTG_OVERRIDE;
245 tresult PLUGIN_API
tell (int64* pos) SMTG_OVERRIDE;
266 DECLARE_FUNKNOWN_METHODS
269 tresult PLUGIN_API
read (
void* buffer, int32 numBytes, int32* numBytesRead =
nullptr) SMTG_OVERRIDE;
270 tresult PLUGIN_API
write (
void* buffer, int32 numBytes, int32* numBytesWritten =
nullptr) SMTG_OVERRIDE;
271 tresult PLUGIN_API
seek (int64 pos, int32 mode, int64* result =
nullptr) SMTG_OVERRIDE;
272 tresult PLUGIN_API
tell (int64* pos) SMTG_OVERRIDE;
292 DECLARE_FUNKNOWN_METHODS
295 tresult PLUGIN_API
read (
void* buffer, int32 numBytes, int32* numBytesRead =
nullptr) SMTG_OVERRIDE;
296 tresult PLUGIN_API
write (
void* buffer, int32 numBytes, int32* numBytesWritten =
nullptr) SMTG_OVERRIDE;
297 tresult PLUGIN_API
seek (int64 pos, int32 mode, int64* result =
nullptr) SMTG_OVERRIDE;
298 tresult PLUGIN_API
tell (int64* pos) SMTG_OVERRIDE;
Handling 16 Byte Globally Unique Identifiers.
Stream implementation for a memory buffer.
tresult PLUGIN_API write(void *buffer, int32 numBytes, int32 *numBytesWritten=nullptr) SMTG_OVERRIDE
Writes binary data to stream.
DECLARE_FUNKNOWN_METHODS tresult PLUGIN_API read(void *buffer, int32 numBytes, int32 *numBytesRead=nullptr) SMTG_OVERRIDE
Reads binary data from stream.
tresult PLUGIN_API tell(int64 *pos) SMTG_OVERRIDE
Gets current stream read-write position.
tresult PLUGIN_API seek(int64 pos, int32 mode, int64 *result=nullptr) SMTG_OVERRIDE
Sets stream read-write position.
Stream implementation for a file using stdio.
tresult PLUGIN_API write(void *buffer, int32 numBytes, int32 *numBytesWritten=nullptr) SMTG_OVERRIDE
Writes binary data to stream.
static IBStream * open(const char *filename, const char *mode)
open a stream using stdio function
tresult PLUGIN_API seek(int64 pos, int32 mode, int64 *result=nullptr) SMTG_OVERRIDE
Sets stream read-write position.
tresult PLUGIN_API tell(int64 *pos) SMTG_OVERRIDE
Gets current stream read-write position.
DECLARE_FUNKNOWN_METHODS tresult PLUGIN_API read(void *buffer, int32 numBytes, int32 *numBytesRead=nullptr) SMTG_OVERRIDE
Reads binary data from stream.
Component base interface: Vst::IComponent.
Edit controller component interface: Vst::IEditController.
Component extension to access program list data: Vst::IProgramListData.
Component extension to access unit data: Vst::IUnitData.
Edit controller extension to describe the plug-in structure: Vst::IUnitInfo.
Handler for a VST 3 Preset File.
const Entry * getEntry(ChunkType which) const
Returns an entry for a given chunk type.
static bool loadPreset(IBStream *stream, const FUID &classID, IComponent *component, IEditController *editController=nullptr, std::vector< FUID > *otherClassIDArray=nullptr)
Shortcut helper to load preset with component/controller state.
void setClassID(const FUID &uid)
Sets the associated classID (component ID: Processor part (not the controller!)).
bool writeHeader()
Writes into the stream the main header.
bool contains(ChunkType which) const
Checks if a given chunk type exist in the stream.
bool writeMetaInfo(const char *xmlBuffer, int32 size=-1, bool forceWriting=false)
Writes the meta XML info, -1 means null-terminated, forceWriting to true will force to rewrite the XM...
const Entry & at(int32 index) const
Returns the entry at a given position.
bool writeChunk(const void *data, int32 size, ChunkType which=kComponentState)
Writes a given data of a given size as "which" chunk type.
bool readMetaInfo(char *xmlBuffer, int32 &size)
Reads the meta XML info and its size, the size could be retrieved by passing zero as xmlBuffer.
bool storeComponentState(IComponent *component)
Stores the component state (only one time).
bool readChunkList()
Reads and build the chunk list (including the header chunk).
const Entry * getLastEntry() const
Returns the last available entry.
int32 getEntryCount() const
Returns the number of total entries in the current stream.
const FUID & getClassID() const
Returns the associated classID (component ID: Processor part (not the controller!)).
IBStream * getStream() const
Returns the associated stream.
bool restoreComponentState(IComponent *component)
Restores the component state.
bool getUnitProgramListID(int32 &unitProgramListID)
Gets the unitProgramListID saved in the kProgramData chunk (if available).
bool writeChunkList()
Writes into the stream the chunk list (should be at the end).
bool seekToControllerState()
Seeks to the begin of the Controller State.
bool storeControllerState(IEditController *editController)
Stores the controller state (only one time).
bool seekToComponentState()
Seeks to the begin of the Component State.
bool prepareMetaInfoUpdate()
checks if meta info chunk is the last one and jump to correct position.
FUID classID
classID is the FUID of the component (processor) part
bool restoreControllerState(IEditController *editController)
Restores the controller state.
static bool savePreset(IBStream *stream, const FUID &classID, IComponent *component, IEditController *editController=nullptr, const char *xmlBuffer=nullptr, int32 xmlSize=-1)
Shortcut helper to create preset from component/controller state.
bool restoreProgramData(IProgramListData *programListData, ProgramListID *programListID=nullptr, int32 programIndex=0)
Restores a IProgramListData with a given identifier and index.
bool storeProgramData(IBStream *inStream, ProgramListID listID)
Store program data or unit data from stream (including the header chunk).
Internal structure used for chunk handling.
Stream representing a Read-Only subsection of its source stream.
DECLARE_FUNKNOWN_METHODS tresult PLUGIN_API read(void *buffer, int32 numBytes, int32 *numBytesRead=nullptr) SMTG_OVERRIDE
Reads binary data from stream.
tresult PLUGIN_API tell(int64 *pos) SMTG_OVERRIDE
Gets current stream read-write position.
tresult PLUGIN_API seek(int64 pos, int32 mode, int64 *result=nullptr) SMTG_OVERRIDE
Sets stream read-write position.
tresult PLUGIN_API write(void *buffer, int32 numBytes, int32 *numBytesWritten=nullptr) SMTG_OVERRIDE
Writes binary data to stream.
int32 ProgramListID
program list identifier
int32 UnitID
unit identifier