本文整理汇总了C++中MemoryBlock::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBlock::getSize方法的具体用法?C++ MemoryBlock::getSize怎么用?C++ MemoryBlock::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBlock
的用法示例。
在下文中一共展示了MemoryBlock::getSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recreate_from_state
static void recreate_from_state(struct SoundPlugin *plugin, hash_t *state){
#if JUCE_LINUX
const MessageManagerLock mmLock;
#endif
Data *data = (Data*)plugin->data;
AudioPluginInstance *audio_instance = data->audio_instance;
if (HASH_has_key(state, "audio_instance_state")) {
const char *stateAsString = HASH_get_chars(state, "audio_instance_state");
MemoryBlock sourceData;
sourceData.fromBase64Encoding(stateAsString);
audio_instance->setStateInformation(sourceData.getData(), sourceData.getSize());
}
if (HASH_has_key(state, "audio_instance_current_program")) {
int current_program = HASH_get_int(state, "audio_instance_current_program");
audio_instance->setCurrentProgram(current_program);
}
if (HASH_has_key(state, "audio_instance_program_state")){
const char *programStateAsString = HASH_get_chars(state, "audio_instance_program_state");
MemoryBlock sourceData;
sourceData.fromBase64Encoding(programStateAsString);
audio_instance->setCurrentProgramStateInformation(sourceData.getData(), sourceData.getSize());
}
if (HASH_has_key(state, "x_pos"))
data->x = HASH_get_int(state, "x_pos");
if (HASH_has_key(state, "y_pos"))
data->y = HASH_get_int(state, "y_pos");
}
示例2: fileClicked
void fileClicked(const File & newFile, const MouseEvent &) override
{
MemoryBlock mb;
bool success = newFile.loadFileAsData(mb);
if (!success)
return;
if (!(newFile.hasFileExtension("ttf") || newFile.hasFileExtension("otf")))
return;
newTypeface = Typeface::createSystemTypefaceFor(mb.getData(), mb.getSize());
updateFont(newTypeface);
}
示例3: compareMemoryWithWildcard
bool CtrlrMIDITransaction::compareMemoryWithWildcard(const MidiMessage &midi, const MemoryBlock &memory)
{
const uint8 *responsePtr = midi.getRawData();
for (size_t i=0; i<memory.getSize(); i++)
{
if (memory[i] == 0xff)
continue;
if (*(responsePtr+i) != memory[i])
return (false);
}
return (true);
}
示例4: create_state
static void create_state(struct SoundPlugin *plugin, hash_t *state){
#if JUCE_LINUX
const MessageManagerLock mmLock;
#endif
Data *data = (Data*)plugin->data;
AudioPluginInstance *audio_instance = data->audio_instance;
// save state
{
MemoryBlock destData;
audio_instance->getStateInformation(destData);
if (destData.getSize() > 0){
String stateAsString = destData.toBase64Encoding();
HASH_put_chars(state, "audio_instance_state", stateAsString.toRawUTF8());
}
}
// save program state
{
MemoryBlock destData;
audio_instance->getCurrentProgramStateInformation(destData);
if (destData.getSize() > 0){
String stateAsString = destData.toBase64Encoding();
HASH_put_chars(state, "audio_instance_program_state", stateAsString.toRawUTF8());
}
}
HASH_put_int(state, "audio_instance_current_program", audio_instance->getCurrentProgram());
HASH_put_int(state, "x_pos", data->x);
HASH_put_int(state, "y_pos", data->y);
}
示例5: menuItemSelected
void HostFilterComponent::menuItemSelected (int menuItemID,
int topLevelMenuIndex)
{
Config* config = Config::getInstance();
GraphComponent* graph = main->getGraph ();
switch (topLevelMenuIndex)
{
case 0: // CommandCategories::file
{
// handle recent plugins selection
int fileID = menuItemID - CommandIDs::recentPlugins;
if (fileID >= 0 && fileID < config->recentPlugins.getNumFiles())
{
File fileToLoad = config->recentPlugins.getFile (fileID);
if (graph)
graph->loadAndAppendPlugin (config->recentPlugins.getFile (fileID), 100, 100);
break;
}
// handle recent session selection
fileID = menuItemID - CommandIDs::recentSessions;
if (fileID >= 0 && fileID < config->recentSessions.getNumFiles())
{
MemoryBlock fileData;
File fileToLoad = config->recentSessions.getFile (fileID);
if (fileToLoad.existsAsFile()
&& fileToLoad.loadFileAsData (fileData))
{
getFilter ()->setStateInformation (fileData.getData (), fileData.getSize());
Config::getInstance()->addRecentSession (fileToLoad);
Config::getInstance()->lastSessionFile = fileToLoad;
}
}
break;
}
}
toFront (true);
}
示例6: itemDropped
void GraphComponent::itemDropped (const String& sourceDescription,
Component* sourceComponent,
int x, int y)
{
if (sourceDescription.startsWith (T("Plugins: ")))
{
StringArray array;
//array.addTokens (sourceDescription.replace (T("Plugins: "), T("")), false);
array.add(sourceDescription.replace (T("Plugins: "), T("")));
if (array.size () > 0)
{
for (int i = 0; i < array.size (); i++)
{
File file (array [i]);
if (file.existsAsFile ())
dropPluginOnTrack (file, x + i * 5, y + i * 5);
}
}
}
else if (sourceDescription.startsWith (T("Sessions: ")))
{
StringArray array;
array.addTokens (sourceDescription.replace (T("Sessions: "), T("")), false);
if (array.size () > 0)
{
File file (array [array.size () - 1]);
MemoryBlock data;
if (file.existsAsFile()
&& file.loadFileAsData (data))
{
Config::getInstance()->addRecentSession (file);
owner->getFilter ()->setStateInformation (data.getData (), data.getSize());
return;
}
}
}
somethingIsBeingDraggedOver = false;
repaint();
}
示例7: dumpTableContents
const String CtrlrMidiInputComparatorSingle::dumpTableContents()
{
String ret;
for (int i=0; i<kMidiMessageType; i++)
{
CtrlrMidiMap &map = getMap((const CtrlrMidiMessageType)i);
if (&map != &mapNull)
{
ret << "\n*****************************************************************************\n";
ret << "\t\tMAP type: " << midiMessageTypeToString((const CtrlrMidiMessageType)i) << ", size=" << STR((uint32)map.size());
ret << "\n*****************************************************************************\n";
for(CtrlrMidiMapIterator itr = map.begin(); itr != map.end(); ++itr)
{
ret << "\n\tindex=" << String(itr->first) << " targets=" << String(itr->second.targets.size());
for (int j=0; j<itr->second.targets.size(); j++)
{
ret << "\n\t\ttarget=" << itr->second.targets[j]->getName();
}
}
ret << "\n*****************************************************************************\n\n";
}
}
ret << "\n*****************************************************************************\n";
ret << "\t\tMAP SysEx " << "size=" << STR((uint32)mapSysEx.size());
ret << "\n*****************************************************************************\n";
for(CtrlrMultiMidiMapIterator itr = mapSysEx.begin(); itr != mapSysEx.end(); ++itr)
{
MemoryBlock bl = itr->first.toMemoryBlock();
ret << "\n\tindex=" << String::toHexString (bl.getData(), (int)bl.getSize(), 1) << " targets=" << String(itr->second.targets.size());
for (int j=0; j<itr->second.targets.size(); j++)
{
ret << "\n\t\ttarget=" << itr->second.targets[j]->getName();
}
}
ret << "\n*****************************************************************************\n\n";
return (ret);
}
示例8: asHex
String asHex(MemoryBlock const& msg, bool newline)
{
size_t const msgSize = msg.getSize();
MemoryBlock result(msgSize * 10, true);
int offset = 0;
for (size_t i = 0; i < msgSize; ++i)
{
if (newline && ((i % 16) == 0))
{
result.copyFrom("\n", offset, 1);
++offset;
}
char dest[100];
sprintf(dest, "%02X ", (unsigned char)(msg[i]));
result.copyFrom(dest, offset, strlen(dest));
offset += strlen(dest);
}
return result.toString();
}
示例9: saveState
//==============================================================================
void StandaloneFilterWindow::saveState()
{
PropertySet* const globalSettings = getGlobalSettings();
FileChooser fc (TRANS("Save current state"),
globalSettings != 0 ? File (globalSettings->getValue (T("lastStateFile")))
: File::nonexistent);
if (fc.browseForFileToSave (true))
{
MemoryBlock data;
filter->getStateInformation (data);
if (! fc.getResult().replaceWithData (data.getData(), data.getSize()))
{
AlertWindow::showMessageBox (AlertWindow::WarningIcon,
TRANS("Error whilst saving"),
TRANS("Couldn't write to the specified file!"));
}
}
}
示例10: WebInputStream
WebInputStream (const String& address, bool isPost, const MemoryBlock& postData,
URL::OpenStreamProgressCallback* progressCallback, void* progressCallbackContext,
const String& headers, int timeOutMs, StringPairArray* responseHeaders,
const int maxRedirects)
: multi (nullptr), curl (nullptr), headerList (nullptr), lastError (CURLE_OK),
contentLength (-1), streamPos (0),
finished (false), skipBytes (0),
postBuffer (nullptr), postPosition (0)
{
statusCode = -1;
if (init() && setOptions (address, timeOutMs, (responseHeaders != nullptr),
maxRedirects, headers, isPost, postData.getSize()))
{
connect (responseHeaders, isPost, postData, progressCallback, progressCallbackContext);
}
else
{
cleanup();
}
}
示例11: encrypt
String EncryptedString::encrypt (const String& stringToEncrypt, const String& publicKey, bool resultAsHex)
{
RSAKey rsaKey (publicKey);
CharPointer_UTF8 stringPointer (stringToEncrypt.toUTF8());
MemoryBlock stringMemoryBlock (stringPointer.getAddress(), stringPointer.sizeInBytes());
BigInteger stringAsData;
stringAsData.loadFromMemoryBlock (stringMemoryBlock);
rsaKey.applyToValue (stringAsData);
if (resultAsHex)
{
MemoryBlock encryptedMemoryBlock (stringAsData.toMemoryBlock());
return String::toHexString ((char*) encryptedMemoryBlock.getData(), (int) encryptedMemoryBlock.getSize(), 0);
}
else
{
return stringAsData.toMemoryBlock().toBase64Encoding();
}
}
示例12: work
void work (const URIs& uris, const lvtk::Atom& atom) override
{
const File file (String::fromUTF8 (path.c_str()));
if (ScopedXml xml = XmlDocument::parse (file))
{
if (ScopedPointer<SamplerSynth> ss = SamplerSynth::create ())
{
if (ss->loadValueTreeXml (*xml))
{
#define compressd_json 1
#if compressd_json
var json;
const bool haveJson = ss->getNestedVariant (json);
#endif
uint8_t buf [2048];
getForge()->set_buffer (buf, 2048);
ObjectRef synth (*getForge(), uris.ksp1_SamplerSynth, ss.release());
respond (synth);
if (haveJson)
{
MemoryBlock block (0, false);
MemoryOutputStream stream (block, false);
GZIPCompressorOutputStream compressed (&stream, 9);
JSON::writeToStream (compressed, json, true);
compressed.flush();
if (block.getSize() > 0)
{
Forge& f = *getForge();
int bufSize = nextPowerOfTwo ((int) block.getSize());
bufSize = nextPowerOfTwo (bufSize);
MemoryBlock buffer ((size_t) bufSize, false);
f.set_buffer ((uint8*) buffer.getData(), buffer.getSize());
lvtk::Atom gzipped (f.write_atom (block.getSize(), 100100));
f.write_raw (block.getData(), block.getSize());
DBG ("SIZE: " << (int)block.getSize());
respond (gzipped);
}
}
}
}
}
}
示例13: loadState
void StandaloneFilterWindow::loadState()
{
PropertySet* const globalSettings = getGlobalSettings();
FileChooser fc (TRANS("Load a saved state"),
globalSettings != 0 ? File (globalSettings->getValue (T("lastStateFile")))
: File::nonexistent);
if (fc.browseForFileToOpen())
{
MemoryBlock data;
if (fc.getResult().loadFileAsData (data))
{
filter->setStateInformation (data.getData(), data.getSize());
}
else
{
AlertWindow::showMessageBox (AlertWindow::WarningIcon,
TRANS("Error whilst loading"),
TRANS("Couldn't read from the specified file!"));
}
}
}
示例14: sendMessage
//==============================================================================
bool InterprocessConnection::sendMessage (const MemoryBlock& message)
{
uint32 messageHeader[2];
messageHeader [0] = ByteOrder::swapIfBigEndian (magicMessageHeader);
messageHeader [1] = ByteOrder::swapIfBigEndian ((uint32) message.getSize());
MemoryBlock messageData (sizeof (messageHeader) + message.getSize());
messageData.copyFrom (messageHeader, 0, sizeof (messageHeader));
messageData.copyFrom (message.getData(), sizeof (messageHeader), message.getSize());
int bytesWritten = 0;
const ScopedLock sl (pipeAndSocketLock);
if (socket != nullptr)
bytesWritten = socket->write (messageData.getData(), (int) messageData.getSize());
else if (pipe != nullptr)
bytesWritten = pipe->write (messageData.getData(), (int) messageData.getSize(), pipeReceiveMessageTimeout);
return bytesWritten == (int) messageData.getSize();
}
示例15: createRequestHeader
static MemoryBlock createRequestHeader (const String& hostName, const int hostPort,
const String& proxyName, const int proxyPort,
const String& hostPath, const String& originalURL,
const String& userHeaders, const MemoryBlock& postData,
const bool isPost)
{
MemoryOutputStream header;
if (proxyName.isEmpty())
writeHost (header, isPost, hostPath, hostName, hostPort);
else
writeHost (header, isPost, originalURL, proxyName, proxyPort);
writeValueIfNotPresent (header, userHeaders, "User-Agent:", "JUCE/" JUCE_STRINGIFY(JUCE_MAJOR_VERSION)
"." JUCE_STRINGIFY(JUCE_MINOR_VERSION)
"." JUCE_STRINGIFY(JUCE_BUILDNUMBER));
writeValueIfNotPresent (header, userHeaders, "Connection:", "Close");
writeValueIfNotPresent (header, userHeaders, "Content-Length:", String ((int) postData.getSize()));
header << "\r\n" << userHeaders
<< "\r\n" << postData;
return header.getMemoryBlock();
}