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


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

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


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

示例1: 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

示例2: isResourceFile

bool ResourceFile::isResourceFile (const File& file)
{
    if (file.hasFileExtension ("cpp;cc;h"))
    {
        ScopedPointer <InputStream> in (file.createInputStream());

        if (in != nullptr)
        {
            MemoryBlock mb;
            in->readIntoMemoryBlock (mb, 256);
            return mb.toString().contains (resourceFileIdentifierString);
        }
    }

    return false;
}
开发者ID:adrien59cadri,项目名称:test,代码行数:16,代码来源:jucer_ResourceFile.cpp

示例3: trimFileSize

void FileLogger::trimFileSize (int maxFileSizeBytes) const
{
    if (maxFileSizeBytes <= 0)
    {
        logFile.deleteFile();
    }
    else
    {
        const int64 fileSize = logFile.getSize();

        if (fileSize > maxFileSizeBytes)
        {
            ScopedPointer <FileInputStream> in (logFile.createInputStream());
            jassert (in != nullptr);

            if (in != nullptr)
            {
                in->setPosition (fileSize - maxFileSizeBytes);
                String content;

                {
                    MemoryBlock contentToSave;
                    contentToSave.setSize ((size_t) maxFileSizeBytes + 4);
                    contentToSave.fillWith (0);

                    in->read (contentToSave.getData(), maxFileSizeBytes);
                    in = nullptr;

                    content = contentToSave.toString();
                }

                int newStart = 0;

                while (newStart < fileSize
                        && content[newStart] != '\n'
                        && content[newStart] != '\r')
                    ++newStart;

                logFile.deleteFile();
                logFile.appendText (content.substring (newStart), false, false);
            }
        }
    }
}
开发者ID:belasco,项目名称:GpxDBImporterExporter,代码行数:44,代码来源:juce_FileLogger.cpp

示例4: initialise

                void initialise(const String& commandLineParameters)
                {
					Logger::writeToLog("CTRLR:initialise params \""+commandLineParameters+"\"");

					SystemStats::setApplicationCrashHandler (&CtrlrApplication::crashHandler);

					if (!commandLineParameters.isEmpty())
					{
						String stackTrace = "?";
						StringArray parameters		= getParameters(commandLineParameters);
						StringArray parameterValues	= getParameterValues(commandLineParameters);

						if (parameters.contains("crashReport"))
						{
							File crashReportForExec(parameterValues[parameters.indexOf("crashReport")]);
							File crashReportFile(crashReportForExec.withFileExtension(crashReportForExec.getFileExtension()+".crash"));
							AlertWindow crashReport("Ctrlr has crashed", "This is a crash indicator, it means that Ctrlr has crashed for some reason. Some crash information will be written to: "+crashReportFile.getFullPathName(), AlertWindow::WarningIcon);

							if (parameters.contains("stackTrace"))
							{
								if (!parameterValues[parameters.indexOf("stackTrace")].isEmpty())
								{
									MemoryBlock mb;
									mb.fromBase64Encoding(parameterValues[parameters.indexOf("stackTrace")]);
									stackTrace = mb.toString();
									crashReport.addTextBlock (stackTrace);
								}
							}
							crashReport.addButton ("OK", 1, KeyPress (KeyPress::returnKey));
							crashReport.runModalLoop();

							crashReportFile.replaceWithText ("Ctrlr crash at: "+Time::getCurrentTime().toString(true, true, true, true) + "\nStack trace:\n"+stackTrace);

							JUCEApplication::quit();
						}
					}


					filterWindow = new CtrlrStandaloneWindow (ProjectInfo::projectName + String("/") + ProjectInfo::versionString, Colours::lightgrey);

					if (File::isAbsolutePath(commandLineParameters.unquoted()))
						filterWindow->openFileFromCli (File(commandLineParameters.unquoted()));
                }
开发者ID:atomicstack,项目名称:ctrlr,代码行数:43,代码来源:CtrlrStandaloneApplication.cpp

示例5: decryptXML

    //==============================================================================
    static XmlElement decryptXML (String hexData, RSAKey rsaPublicKey)
    {
        BigInteger val;
        val.parseString (hexData, 16);

        RSAKey key (rsaPublicKey);
        jassert (key.isValid());

        ScopedPointer<XmlElement> xml;

        if (! val.isZero())
        {
            key.applyToValue (val);

            const MemoryBlock mb (val.toMemoryBlock());

            if (CharPointer_UTF8::isValidString (static_cast<const char*> (mb.getData()), (int) mb.getSize()))
                xml = XmlDocument::parse (mb.toString());
        }

        return xml != nullptr ? *xml : XmlElement("key");
    }
开发者ID:azeteg,项目名称:HISE,代码行数:23,代码来源:juce_OnlineUnlockStatus.cpp

示例6: messageReceived

 void messageReceived (const MemoryBlock& message)
 {
     owner.appendMessage ("Connection #" + String (ourNumber) + " - message received: " + message.toString());
 }
开发者ID:adrien59cadri,项目名称:test,代码行数:4,代码来源:InterprocessCommsDemo.cpp

示例7: if


//.........这里部分代码省略.........
                        if (length <= 18)
                        {
                            // some types don't have a chunk large enough to include a compression
                            // type, so assume it's just big-endian pcm
                            littleEndian = false;
                        }
                        else
                        {
                            const int compType = input->readInt();

                            if (compType == chunkName ("NONE") || compType == chunkName ("twos"))
                            {
                                littleEndian = false;
                            }
                            else if (compType == chunkName ("sowt"))
                            {
                                littleEndian = true;
                            }
                            else
                            {
                                sampleRate = 0;
                                break;
                            }
                        }
                    }
                    else if (type == chunkName ("SSND"))
                    {
                        hasGotData = true;

                        const int offset = input->readIntBigEndian();
                        dataChunkStart = input->getPosition() + 4 + offset;
                        lengthInSamples = (bytesPerFrame > 0) ? jmin (lengthInSamples, (int64) (length / bytesPerFrame)) : 0;
                    }
                    else if (type == chunkName ("MARK"))
                    {
                        const uint16 numCues = (uint16) input->readShortBigEndian();

                        // these two are always the same for AIFF-read files
                        metadataValues.set ("NumCuePoints", String (numCues));
                        metadataValues.set ("NumCueLabels", String (numCues));

                        for (uint16 i = 0; i < numCues; ++i)
                        {
                            uint16 identifier = (uint16) input->readShortBigEndian();
                            uint32 offset = (uint32) input->readIntBigEndian();
                            uint8 stringLength = (uint8) input->readByte();
                            MemoryBlock textBlock;
                            input->readIntoMemoryBlock (textBlock, stringLength);

                            // if the stringLength is even then read one more byte as the
                            // string needs to be an even number of bytes INCLUDING the
                            // leading length character in the pascal string
                            if ((stringLength & 1) == 0)
                                input->readByte();

                            const String prefixCue ("Cue" + String (i));
                            metadataValues.set (prefixCue + "Identifier", String (identifier));
                            metadataValues.set (prefixCue + "Offset", String (offset));

                            const String prefixLabel ("CueLabel" + String (i));
                            metadataValues.set (prefixLabel + "Identifier", String (identifier));
                            metadataValues.set (prefixLabel + "Text", textBlock.toString());
                        }
                    }
                    else if (type == chunkName ("COMT"))
                    {
                        const uint16 numNotes = (uint16) input->readShortBigEndian();
                        metadataValues.set ("NumCueNotes", String (numNotes));

                        for (uint16 i = 0; i < numNotes; ++i)
                        {
                            uint32 timestamp = (uint32) input->readIntBigEndian();
                            uint16 identifier = (uint16) input->readShortBigEndian(); // may be zero in this case
                            uint16 stringLength = (uint16) input->readShortBigEndian();

                            MemoryBlock textBlock;
                            input->readIntoMemoryBlock (textBlock, stringLength + (stringLength & 1));

                            const String prefix ("CueNote" + String (i));
                            metadataValues.set (prefix + "TimeStamp", String (timestamp));
                            metadataValues.set (prefix + "Identifier", String (identifier));
                            metadataValues.set (prefix + "Text", textBlock.toString());
                        }
                    }
                    else if (type == chunkName ("INST"))
                    {
                        HeapBlock <InstChunk> inst;
                        inst.calloc (jmax ((size_t) length + 1, sizeof (InstChunk)), 1);
                        input->read (inst, length);
                        inst->copyTo (metadataValues);
                    }
                    else if ((hasGotVer && hasGotData && hasGotType)
                             || chunkEnd < input->getPosition()
                             || input->isExhausted())
                    {
                        break;
                    }

                    input->setPosition (chunkEnd);
                }
开发者ID:EQ4,项目名称:editor,代码行数:101,代码来源:juce_AiffAudioFormat.cpp

示例8: if

void NetworkConnection::ClientConnection::messageReceived (const MemoryBlock & message)
{
    // When some data is received : Do something using Owner

	/*String fileName=message.toString();
	String fileExtention=*/
     
	if(isFirstCall)
		{
		
			if(messageProtocols.isFirstTimeName(message.toString(), clientInfo.clientName))
			{
				firstTimeNameHandle();
			}
			else if(messageProtocols.isConnectTimeName(message.toString(), clientInfo.clientName))
			{
				connectTimeNameHandle();
			}
			isFirstCall = false;
			return;
		}
		String dataToSend, otherdataToSend;
		// Now it has to be normal connection and communicate after first connection time
		if(messageProtocols.isAcquireLockMessage(message.toString()))
		{
			if(ownerControlBarComponent->manageServerLock(true))
			{
				clientInfo.hasLock = true;
				dataToSend = messageProtocols.constructAllowLock();
				ownerControlBarComponent->getClientListComponent()->setClientHasLock(clientInfo);
				ownerServer.sendOtherThatServerIslocked(true, clientInfo.clientName);
				// Send info to clientListComponent also...
			}
			else
			{
				clientInfo.hasLock = false;
				dataToSend = messageProtocols.constructDenyLock();
				// No need to send data to clientListComp...
			}
			MemoryBlock messageData(dataToSend.toUTF8(), dataToSend.getNumBytesAsUTF8());
			sendMessage(messageData);
			if(clientInfo.hasLock)
			{
				int index;
				if(ownerControlBarComponent->getPlayerComponent()->isCurrentlyPlaying(index))
				{
					dataToSend = messageProtocols.constructPlayingIndex(String(index));
					MemoryBlock messageData(dataToSend.toUTF8(), dataToSend.getNumBytesAsUTF8());
					sendMessage(messageData);
				}
			}
		}
		else if(messageProtocols.isReleaseLockMessage(message.toString()))
		{
			ownerControlBarComponent->manageServerLock(false);
			clientInfo.hasLock = false;
			ownerControlBarComponent->getClientListComponent()->setClientHasLock(clientInfo);
			ownerServer.sendOtherThatServerIslocked(false);
		}
		// Only check for these messages when client has lock
		else if(clientInfo.hasLock)
		{
			if(messageProtocols.isPlayMessage(message.toString()))
			{
				ownerControlBarComponent->getPlayerComponent()->playPauseButtonClicked();
			}
			else if(messageProtocols.isPlayAfterStopMessage(message.toString(), dataToSend))
			{
				ownerControlBarComponent->getPlayListComponent()->songPlayedByClick(dataToSend.getIntValue());
			}
			else if(messageProtocols.isPauseMessage(message.toString()))
			{
				ownerControlBarComponent->getPlayerComponent()->playPauseButtonClicked();
			}
			else if(messageProtocols.isStopMessage(message.toString()))
			{
				ownerControlBarComponent->getPlayerComponent()->signalThreadShouldExit();
				ownerControlBarComponent->getPlayerComponent()->stopButtonClicked();
			}
			else if(messageProtocols.isBackMessage(message.toString()))
			{
				ownerControlBarComponent->getPlayerComponent()->backButtonClicked();
			}
			else if(messageProtocols.isNextMessage(message.toString()))
			{
				ownerControlBarComponent->getPlayerComponent()->nextButtonClicked();
			}
			else if(messageProtocols.isAddInPlayList(message.toString(), dataToSend))
			{
				ownerControlBarComponent->getPlayListComponent()->addInPlayListFromClient(dataToSend);
				ownerServer.sendAddInPlayList(dataToSend, clientInfo.clientIpAddress);
			}
			else if(messageProtocols.isDropInPlayList(message.toString(), dataToSend, otherdataToSend))
			{
				ownerControlBarComponent->getPlayListComponent()->dropInPlayListFromClient(dataToSend, otherdataToSend.getIntValue());
				ownerServer.sendDropInPlayList(dataToSend, otherdataToSend.getIntValue(), clientInfo.clientIpAddress);
			}
			else if(messageProtocols.isdragDropPlayListMessage (message.toString(), dataToSend, otherdataToSend))
			{
				ownerControlBarComponent->getPlayListComponent()->itemDroppedFromClient(dataToSend, otherdataToSend);
//.........这里部分代码省略.........
开发者ID:cyberCBM,项目名称:ScPlayer,代码行数:101,代码来源:NetworkConnection.cpp


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