本文整理汇总了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;
}
}
示例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;
}
示例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);
}
}
}
}
示例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()));
}
示例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");
}
示例6: messageReceived
void messageReceived (const MemoryBlock& message)
{
owner.appendMessage ("Connection #" + String (ourNumber) + " - message received: " + message.toString());
}
示例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);
}
示例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);
//.........这里部分代码省略.........