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


C++ MemoryBlock类代码示例

本文整理汇总了C++中MemoryBlock的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBlock类的具体用法?C++ MemoryBlock怎么用?C++ MemoryBlock使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MemoryBlock类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: beginRequestHandler

static int beginRequestHandler(struct mg_connection *conn) {
    enum BeginRequestHandlerReturnValues { HANDLED = 1, NOT_HANDLED = 0 };

    struct mg_request_info *info = mg_get_request_info(conn);
    String uri(info->uri);
    if (!uri.endsWithIgnoreCase(".json") && !uri.endsWithIgnoreCase(".wav")) {
        // DBG << "Not handling as audio request" << endl;
        return NOT_HANDLED;
    }

    // DBG << "Handling URI: " << uri << endl;

    var parsed;
    // First try to look in the query string
    String queryString = urldecode(info->query_string);
    // DBG << queryString << endl;
    parsed = JSON::parse(queryString);
    // Otherwise look in the POST data
    if (!parsed) {
        MemoryBlock postDataBlock;
        char postBuffer[1024];
        int didRead;
        while ((didRead = mg_read(conn, postBuffer, sizeof(postBuffer)))) {
            postDataBlock.append(postBuffer, didRead);
        }
        MemoryInputStream postStream(postDataBlock, false);
        parsed = JSON::parse(postStream);
    }

    DBG << "Request JSON: " << JSON::toString(parsed, true) << endl;

    PluginRequestParameters params(parsed);
    if (uri.endsWithIgnoreCase(".json")) {
        params.listParameters = true;
    }

    MemoryBlock block;
    MemoryOutputStream ostream(block, false);

    // DBG << "Rendering plugin request" << endl;
    int64 startTime = Time::currentTimeMillis();
    bool result = handlePluginRequest(params, ostream);
    if (!result) {
        DBG << "-> Unable to handle plugin request!" << endl;
        mg_printf(conn, "HTTP/1.0 500 ERROR\r\n\r\n");
        return HANDLED;
    }
    DBG << "-> Rendered plugin request in " << (Time::currentTimeMillis() - startTime) << "ms" << endl;

    // Note: MemoryOutputStream::getDataSize() is the actual number of bytes written.
    // Do not use MemoryBlock::getSize() since this reports the memory allocated (but not initialized!)
    mg_printf(conn, "HTTP/1.0 200 OK\r\n"
              "Content-Length: %d\r\n"
              "Content-Type: %s\r\n"
              "\r\n",
              (int)ostream.getDataSize(), params.getContentType());
    mg_write(conn, ostream.getData(), ostream.getDataSize());

    return HANDLED;
}
开发者ID:bpartridge,项目名称:jucebouncer,代码行数:60,代码来源:main.cpp

示例2:

void CtrlrLuaAudioConverter::convertInt16 (MemoryBlock &sourceData, AudioSampleBuffer &destination, const int numSamples, const int numChannels, const bool interleaved)
{
	if (interleaved)
	{
		AudioData::ConverterInstance <	AudioData::Pointer <AudioData::Int16,
																		AudioData::NativeEndian,
																		AudioData::Interleaved,
																		AudioData::Const>, 
													AudioData::Pointer <AudioData::Float32,
																		AudioData::NativeEndian,
																		AudioData::Interleaved,
																		AudioData::NonConst>
									> converter;
		for (int ch=0; ch<numChannels; ch++)
		{
			converter.convertSamples ((void *)destination.getReadPointer(ch), sourceData.getData(), numSamples);
		}
	}
	else
	{
		AudioData::ConverterInstance <	AudioData::Pointer <AudioData::Int16,
																		AudioData::NativeEndian,
																		AudioData::NonInterleaved,
																		AudioData::Const>, 
													AudioData::Pointer <AudioData::Float32,
																		AudioData::NativeEndian,
																		AudioData::Interleaved,
																		AudioData::NonConst>
									> converter;
		for (int ch=0; ch<numChannels; ch++)
		{
			converter.convertSamples ((void *)destination.getReadPointer(ch), ch, sourceData.getData(), ch, numSamples);
		}
	}
}
开发者ID:Srikrishna31,项目名称:ctrlr,代码行数:35,代码来源:CtrlrLuaAudioConverter.cpp

示例3: createFromHexData

const MidiMessage createFromHexData (const String &hexData)
{
	MemoryBlock bl;
	bl.loadFromHexString(hexData);

	return (MidiMessage ((uint8*)bl.getData(), (int)bl.getSize()));
}
开发者ID:Srikrishna31,项目名称:ctrlr,代码行数:7,代码来源:CtrlrUtilities.cpp

示例4: Results

void Tester_68k::sampleNot() {
    Results* oObj;
    MemoryBlock* oSampleMem;

    oObj = new Results("NOT.B D0");
    oObj->setRegD(0, 0x12345687);
    oObj->setN();
    oObj->setCycleCount(4);

    oObj = new Results("NOT.W D0");
    oObj->setRegD(0, 0x1234ffff);
    oObj->setN()->setX();
    oObj->setCycleCount(4);

    oObj = new Results("NOT.L D0");
    oObj->setRegD(0, 0x000000ff);
    oObj->setX();
    oObj->setCycleCount(6);
    oObj->setIrqSampleCyclePos(2);

    oObj = new Results("NOT.L ($3000).L");
    oObj->setX();
    oSampleMem = new MemoryBlock();
    oSampleMem->writeLong(0x3000, 0x0ffedcee);
    oObj->setCodeBlock(oSampleMem);
    oObj->setCycleCount(28);
}
开发者ID:ctessler,项目名称:fork68k,代码行数:27,代码来源:not.cpp

示例5: save_fxbp

static void save_fxbp(SoundPlugin *plugin, wchar_t *wfilename, bool is_fxb){
  Data *data = (Data*)plugin->data;
  AudioPluginInstance *instance = data->audio_instance;

  MemoryBlock memoryBlock;
  bool result = VSTPluginFormat::saveToFXBFile(instance, memoryBlock, is_fxb);
  if (result==false){
    GFX_Message(NULL, "Unable to create FXB/FXP data for this plugin");
    return;
  }
  
  String filename(wfilename);

  File file(filename);

  Result result2 = file.create();

  if (result2.failed()){
    GFX_Message(NULL, "Unable to create file %s (%s)", STRING_get_chars(wfilename), result2.getErrorMessage().toRawUTF8());
    return;
  }
  
  bool result3 = file.replaceWithData(memoryBlock.getData(), memoryBlock.getSize());
  if (result3==false){
    GFX_Message(NULL, "Unable to write data to file %s (disk full?)", STRING_get_chars(wfilename));
    return;
  }
  
  
  printf("\n\n\n ***************** result: %d\n\n\n\n",result);
}
开发者ID:erdoukki,项目名称:radium,代码行数:31,代码来源:Juce_plugins.cpp

示例6: clear

void NamedValueSet::setFromXmlAttributes (const XmlElement& xml)
{
    clear();
    LinkedListPointer<NamedValue>::Appender appender (values);

    const int numAtts = xml.getNumAttributes(); // xxx inefficient - should write an att iterator..

    for (int i = 0; i < numAtts; ++i)
    {
        const String& name  = xml.getAttributeName (i);
        const String& value = xml.getAttributeValue (i);

        if (name.startsWith ("base64:"))
        {
            MemoryBlock mb;

            if (mb.fromBase64Encoding (value))
            {
                appender.append (new NamedValue (name.substring (7), var (mb)));
                continue;
            }
        }

        appender.append (new NamedValue (name, var (value)));
    }
}
开发者ID:2DaT,项目名称:Obxd,代码行数:26,代码来源:juce_NamedValueSet.cpp

示例7: messageReceived

void BenderControlConnectionHandler::messageReceived (const MemoryBlock &message)
{
	if (message.getSize() <= 2)
		return;

	BenderControlMessageType type = getControlMessageType (message);

	switch (type)
	{
		case helo:
			respondToHelo(message);
			return;

		case streamData:
			respondToStreamDataRequest(message);
			return;

		case setMotor:
			respondToSetMotorRequest(message);
			return;

		default:
			_DBG("\tunknown message received ["+message.toString()+"]");
			break;
	}
}
开发者ID:RomanKubiak,项目名称:bender,代码行数:26,代码来源:BenderControlServer.cpp

示例8: temp

const Result CtrlrWindows::getDefaultResources(MemoryBlock& dataToWrite)
{
#ifdef DEBUG_INSTANCE
	File temp("c:\\devel\\debug_small.bpanelz");

	MemoryBlock data;
	{
		ScopedPointer <FileInputStream> fis (temp.createInputStream());
		fis->readIntoMemoryBlock (data);
	}

	ValueTree t = ValueTree::readFromGZIPData(data.getData(), data.getSize());

	if (t.isValid())
	{
		ValueTree r = t.getChildWithName (Ids::resourceExportList);
		if (r.isValid())
		{
			MemoryOutputStream mos (dataToWrite, false);
			{
				GZIPCompressorOutputStream gzipOutputStream (&mos);
				r.writeToStream(gzipOutputStream);
				gzipOutputStream.flush();
			}
			return (Result::ok());
		}
	}
	else
	{
		return (Result::fail("Windows Native: getDefaultResources got data but couldn't parse it as a compressed ValueTree"));
	}
#endif

	return (readResource (nullptr, MAKEINTRESOURCE(CTRLR_INTERNAL_RESOURCES_RESID), RT_RCDATA, dataToWrite));
}
开发者ID:RomanKubiak,项目名称:ctrlr,代码行数:35,代码来源:CtrlrWindows.cpp

示例9:

OutputStream& JUCE_CALLTYPE operator<< (OutputStream& stream, const MemoryBlock& data)
{
    if (data.getSize() > 0)
        stream.write (data.getData(), (int) data.getSize());

    return stream;
}
开发者ID:Frongo,项目名称:JUCE,代码行数:7,代码来源:juce_OutputStream.cpp

示例10:

BEAST_API OutputStream& BEAST_CALLTYPE operator<< (OutputStream& stream, const MemoryBlock& data)
{
    if (data.getSize() > 0)
        stream.write (data.getData(), data.getSize());

    return stream;
}
开发者ID:AUSTRALIANBITCOINS,项目名称:rippled,代码行数:7,代码来源:beast_OutputStream.cpp

示例11: crashHandler

				static void crashHandler()
				{
					if (JUCEApplication::isStandaloneApp())
					{
						MemoryBlock mb (SystemStats::getStackBacktrace().toUTF8(), SystemStats::getStackBacktrace().length());
						File::getSpecialLocation(File::currentApplicationFile)
							.startAsProcess("--crashReport=\""
											+File::getSpecialLocation(File::currentApplicationFile).getFullPathName()
											+"\" --stackTrace=\""+mb.toBase64Encoding()
											+"\"");
					}
					else
					{
						const String stackTrace = SystemStats::getStackBacktrace();
						File crashFile (File::getSpecialLocation(File::currentApplicationFile).getFileExtension()+".crash");

						AlertWindow::showMessageBox (AlertWindow::WarningIcon,
														"Ctrlr has crashed",
														"Looks like Ctrlr has crashed, since this is not a standalone instance, we won't do anything.\
														A crash log will be written to "+crashFile.getFullPathName()
														+"\n\n"+stackTrace);

						crashFile.replaceWithText ("Ctrlr crash at: "+Time::getCurrentTime().toString(true, true, true, true) + "\nStack trace:\n"+stackTrace);
					}
				}
开发者ID:atomicstack,项目名称:ctrlr,代码行数:25,代码来源:CtrlrStandaloneApplication.cpp

示例12: getGlobalSettings

StandaloneFilterWindow::~StandaloneFilterWindow()
{
    PropertySet* const globalSettings = getGlobalSettings();

    globalSettings->setValue (T("windowX"), getX());
    globalSettings->setValue (T("windowY"), getY());

    deleteAndZero (optionsButton);

    if (globalSettings != 0 && deviceManager != 0)
    {
        XmlElement* const xml = deviceManager->createStateXml();
        globalSettings->setValue (T("audioSetup"), xml);
        delete xml;
    }

    if (globalSettings != 0 && filter != 0)
    {
        MemoryBlock data;
        filter->getStateInformation (data);

        globalSettings->setValue (T("filterState"), data.toBase64Encoding());
    }

    deleteAndZero (deviceManager);

    deleteFilter();
}
开发者ID:christianscheuer,项目名称:jivemodular,代码行数:28,代码来源:juce_StandaloneFilterWindow.cpp

示例13: getBinaryValue

    static std::uint32_t getBinaryValue (const String& regValuePath, MemoryBlock& result, DWORD wow64Flags)
    {
        const RegistryKeyWrapper key (regValuePath, false, wow64Flags);

        if (key.key != 0)
        {
            for (unsigned long bufferSize = 1024; ; bufferSize *= 2)
            {
                result.setSize (bufferSize, false);
                DWORD type = REG_NONE;

                const LONG err = RegQueryValueEx (key.key, key.wideCharValueName, 0, &type,
                                                  (LPBYTE) result.getData(), &bufferSize);

                if (err == ERROR_SUCCESS)
                {
                    result.setSize (bufferSize, false);
                    return type;
                }

                if (err != ERROR_MORE_DATA)
                    break;
            }
        }

        return REG_NONE;
    }
开发者ID:BattleProgrammer,项目名称:stellard,代码行数:27,代码来源:win32_Registry.cpp

示例14: myChooser

void HostFilterComponent::handleSaveCommand(bool saveToExistingFileAndDontPrompt)
{
   File tmp = currentSessionFile;
   
   bool userConfirmed = true;
   if (!saveToExistingFileAndDontPrompt || !tmp.exists())
   {
      FileChooser myChooser (T("Save Session..."),
                              currentSessionFile.exists() ? tmp : Config::getInstance ()->lastSessionDirectory,
                              JOST_SESSION_WILDCARD,
                              JOST_USE_NATIVE_FILE_CHOOSER);

      if (myChooser.browseForFileToSave (true))
         tmp = myChooser.getResult().withFileExtension (JOST_SESSION_EXTENSION);
      else
         userConfirmed = false;      
   }
   
   if (userConfirmed && (tmp != File::nonexistent))
   {
      MemoryBlock fileData;
      getFilter ()->getStateInformation (fileData);

      if (tmp.replaceWithData (fileData.getData (), fileData.getSize()))
      {
         Config::getInstance()->addRecentSession (tmp);
         setCurrentSessionFile(tmp);
         Config::getInstance()->lastSessionFile = tmp;
      }
   }
}
开发者ID:christianscheuer,项目名称:jivemodular,代码行数:31,代码来源:HostFilterComponent.cpp

示例15: load

void OnlineUnlockStatus::load()
{
    MemoryBlock mb;
    mb.fromBase64Encoding (getState());

    if (mb.getSize() > 0)
        status = ValueTree::readFromGZIPData (mb.getData(), mb.getSize());
    else
        status = ValueTree (stateTagName);

    StringArray localMachineNums (getLocalMachineIDs());

    if (machineNumberAllowed (StringArray ("1234"), localMachineNums))
        status.removeProperty (unlockedProp, nullptr);

    KeyFileUtils::KeyFileData data;
    data = KeyFileUtils::getDataFromKeyFile (KeyFileUtils::getXmlFromKeyFile (status[keyfileDataProp], getPublicKey()));

    if (data.keyFileExpires)
    {
        if (! doesProductIDMatch (data.appID))
            status.removeProperty (expiryTimeProp, nullptr);

        if (! machineNumberAllowed (data.machineNumbers, localMachineNums))
            status.removeProperty (expiryTimeProp, nullptr);
    }
    else
    {
        if (! doesProductIDMatch (data.appID))
            status.removeProperty (unlockedProp, nullptr);

        if (! machineNumberAllowed (data.machineNumbers, localMachineNums))
            status.removeProperty (unlockedProp, nullptr);
    }
}
开发者ID:azeteg,项目名称:HISE,代码行数:35,代码来源:juce_OnlineUnlockStatus.cpp


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