当前位置: 首页>>代码示例>>C++>>正文


C++ MemoryBlock::getSize方法代码示例

本文整理汇总了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");
}
开发者ID:erdoukki,项目名称:radium,代码行数:36,代码来源:Juce_plugins.cpp

示例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);
	}
开发者ID:SonicZentropy,项目名称:ZynVerb,代码行数:15,代码来源:font_and_colour_designer.cpp

示例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);
}
开发者ID:gareth8118,项目名称:ctrlr,代码行数:15,代码来源:CtrlrMIDITransaction.cpp

示例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);
}
开发者ID:erdoukki,项目名称:radium,代码行数:36,代码来源:Juce_plugins.cpp

示例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);
}
开发者ID:christianscheuer,项目名称:jivemodular,代码行数:44,代码来源:HostFilterComponent.cpp

示例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();
}
开发者ID:alessandropetrolati,项目名称:juced,代码行数:44,代码来源:GraphComponent.cpp

示例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);
}
开发者ID:RomanKubiak,项目名称:ctrlr,代码行数:41,代码来源:CtrlrMidiInputComparatorSingle.cpp

示例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();
}
开发者ID:jabelardo,项目名称:GIRL,代码行数:21,代码来源:UtilString.cpp

示例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!"));
        }
    }
}
开发者ID:christianscheuer,项目名称:jivemodular,代码行数:22,代码来源:juce_StandaloneFilterWindow.cpp

示例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();
        }
    }
开发者ID:AndyJBuchanan,项目名称:dexed,代码行数:21,代码来源:juce_curl_Network.cpp

示例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();
    }
}
开发者ID:alessandrostone,项目名称:drowaudio,代码行数:22,代码来源:dRowAudio_EncryptedString.cpp

示例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);
                                }
                            }
                        }
                    }
                }
            }
开发者ID:kushview,项目名称:ksp1,代码行数:45,代码来源:Jobs.cpp

示例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!"));
        }
    }
}
开发者ID:christianscheuer,项目名称:jivemodular,代码行数:24,代码来源:juce_StandaloneFilterWindow.cpp

示例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();
}
开发者ID:0x4d52,项目名称:KlangFalter,代码行数:22,代码来源:juce_InterprocessConnection.cpp

示例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();
    }
开发者ID:sonic59,项目名称:JuceEditor,代码行数:24,代码来源:juce_linux_Network.cpp


注:本文中的MemoryBlock::getSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。