本文整理汇总了C++中MemoryBlock::replaceWith方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBlock::replaceWith方法的具体用法?C++ MemoryBlock::replaceWith怎么用?C++ MemoryBlock::replaceWith使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBlock
的用法示例。
在下文中一共展示了MemoryBlock::replaceWith方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPatchAndEnvStatesAsBinary
void MLPluginProcessor::getPatchAndEnvStatesAsBinary (MemoryBlock& destData)
{
// get processor state as JSON
cJSON* procRoot = cJSON_CreateObject();
if(procRoot)
{
mpPatchState->getStateAsJSON(procRoot);
}
// get environment state as JSON
cJSON* envRoot = cJSON_CreateObject();
if(envRoot)
{
mpEnvironmentState->getStateAsJSON(envRoot);
}
// combine the states
cJSON* combinedRoot = cJSON_CreateObject();
std::string combinedStateStr;
if(combinedRoot)
{
cJSON_AddItemToObject(combinedRoot, "patch", procRoot);
cJSON_AddItemToObject(combinedRoot, "environment", envRoot);
combinedStateStr = cJSON_Print(combinedRoot);
}
if(combinedStateStr.length() > 0)
{
// TODO compress here
int stateStrLen = combinedStateStr.size();
destData.replaceWith(combinedStateStr.data(), stateStrLen);
}
}
示例2: sizeof
//==============================================================================
void C74GenAudioProcessor::getStateInformation (MemoryBlock& destData)
{
// You should use this method to store your parameters in the memory block.
// You could do that either as raw data, or use the XML or ValueTree classes
// as intermediaries to make it easy to save and load complex data.
char *state;
size_t statesize = C74_GENPLUGIN::getstatesize(m_C74PluginState);
state = (char *)malloc(sizeof(char) * statesize);
C74_GENPLUGIN::getstate(m_C74PluginState, state);
destData.replaceWith(state, sizeof(char) * statesize);
if (state) free(state);
}