本文整理汇总了C++中StdBuf::getData方法的典型用法代码示例。如果您正苦于以下问题:C++ StdBuf::getData方法的具体用法?C++ StdBuf::getData怎么用?C++ StdBuf::getData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StdBuf
的用法示例。
在下文中一共展示了StdBuf::getData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDbgRecPktData
StdStrBuf GetDbgRecPktData(C4RecordChunkType eType, const StdBuf &RawData) {
StdStrBuf r;
switch (eType) {
case RCT_AulFunc:
r.Ref(reinterpret_cast<const char *>(RawData.getData()),
RawData.getSize() - 1);
break;
default:
for (int i = 0; i < RawData.getSize(); ++i)
r.AppendFormat("%02x ", (uint32_t)((uint8_t *)RawData.getData())[i]);
break;
}
return r;
}
示例2: SSearch
size_t C4Network2IRCClient::UnpackPacket(const StdBuf &rInBuf, const C4NetIO::addr_t &addr)
{
// Find line seperation
const char *pSep = reinterpret_cast<const char *>(memchr(rInBuf.getData(), '\n', rInBuf.getSize()));
if(!pSep)
return 0;
// Check if it's actually correct seperation (rarely the case)
int iSize = pSep - getBufPtr<char>(rInBuf) + 1,
iLength = iSize - 1;
if(iLength && *(pSep - 1) == '\r')
iLength--;
// Copy the line
StdStrBuf Buf; Buf.Copy(getBufPtr<char>(rInBuf), iLength);
// Ignore prefix
const char *pMsg = Buf.getData();
StdStrBuf Prefix;
if(*pMsg == ':')
{
Prefix.CopyUntil(pMsg + 1, ' ');
pMsg += Prefix.getLength() + 1;
}
// Strip whitespace
while(*pMsg == ' ')
pMsg++;
// Ignore empty message
if(!*pMsg)
return iSize;
// Get command
StdStrBuf Cmd; Cmd.CopyUntil(pMsg, ' ');
// Precess command
const char *szParameters = SSearch(pMsg, " ");
OnCommand(Prefix.getData(), Cmd.getData(), szParameters ? szParameters : "");
// Consume the line
return iSize;
}
示例3: if
size_t C4AulDebug::UnpackPacket(const StdBuf &rInBuf, const C4NetIO::addr_t &addr)
{
// Find line separation
const char *pSep = reinterpret_cast<const char *>(memchr(rInBuf.getData(), '\n', rInBuf.getSize()));
if (!pSep)
return 0;
// Check if it's windows-style separation
int iSize = pSep - getBufPtr<char>(rInBuf) + 1,
iLength = iSize - 1;
if (iLength && *(pSep - 1) == '\r')
iLength--;
// Copy the line
StdStrBuf Buf; Buf.Copy(getBufPtr<char>(rInBuf), iLength);
// Password line?
if (fConnected)
{
ProcessLineResult result = ProcessLine(Buf);
// Send answer
SendLine(result.okay ? "OK" : "ERR", result.answer.length() > 0 ? result.answer.c_str() : NULL);
}
else if (!Password.getSize() || Password == Buf)
{
fConnected = true;
SendLine("HLO", "This is " C4ENGINECAPTION ", " C4VERSION);
Log("C4Aul debugger connected successfully!");
}
else
C4NetIOTCP::Close(PeerAddr);
// Consume line
return iSize;
}
示例4: Raw
void StdCompilerINIRead::Raw(void *pData, size_t iSize, RawCompileType eType)
{
// Read data
StdBuf Buf = ReadString(iSize, eType, false);
// Correct size?
if (Buf.getSize() != iSize)
Warn("got %u bytes raw data, but %u bytes expected!", Buf.getSize(), iSize);
// Copy
MemCopy(Buf.getData(), pData, iSize);
}
示例5: sFileContentsString
bool C4KeyboardInput::LoadCustomConfig()
{
// load from INI file (2do: load from registry)
C4Group GrpExtra;
if (!GrpExtra.Open(C4CFN_Extra)) return false;
StdBuf sFileContents;
if (!GrpExtra.LoadEntry(C4CFN_KeyConfig, &sFileContents)) return false;
StdStrBuf sFileContentsString((const char *) sFileContents.getData());
if (!CompileFromBuf_LogWarn<StdCompilerINIRead>(*this, sFileContentsString, "Custom keys from" C4CFN_Extra DirSep C4CFN_KeyConfig))
return false;
LogF(LoadResStr("IDS_PRC_LOADEDKEYCONF"), C4CFN_Extra DirSep C4CFN_KeyConfig);
return true;
}
示例6: SCopy
BOOL C4SoundEffect::Load(const char *szFileName, C4Group &hGroup,
BOOL fStatic) {
// Sound check
if (!Config.Sound.RXSound) return FALSE;
// Locate sound in file
StdBuf WaveBuffer;
if (!hGroup.LoadEntry(szFileName, WaveBuffer)) return FALSE;
// load it from mem
if (!Load((BYTE *)WaveBuffer.getData(), WaveBuffer.getSize(), fStatic))
return FALSE;
// Set name
SCopy(szFileName, Name, C4MaxSoundName);
return TRUE;
}
示例7: ReadString
StdBuf StdCompilerINIRead::ReadString(size_t iLength, RawCompileType eRawType, bool fAppendNull)
{
// Excpect valid position
if (!pPos)
{ notFound("String"); return StdBuf(); }
// Skip whitespace
SkipWhitespace();
// Escaped? Go over '"'
if (eRawType == RCT_Escaped && *pPos++ != '"')
{ notFound("Escaped string"); return StdBuf(); }
// Create buffer
StdBuf OutBuf; OutBuf.New(iLength + (fAppendNull ? sizeof('\0') : 0));
// Read
char *pOut = getMBufPtr<char>(OutBuf);
while (iLength && !TestStringEnd(eRawType))
{
// Read a character
if (eRawType == RCT_Escaped)
*pOut++ = ReadEscapedChar();
else
*pOut++ = *pPos++;
// Count it
iLength--;
}
// Escaped: Go over '"'
if (eRawType == RCT_Escaped)
{
while (*pPos != '"')
{
if (!*pPos || *pPos == '\n' || *pPos == '\r')
{
Warn("string not terminated!");
pPos--;
break;
}
pPos++;
}
pPos++;
}
// Nothing read? Identifiers need to be non-empty
if (pOut == OutBuf.getData() && (eRawType == RCT_Idtf || eRawType == RCT_ID))
{ notFound("String"); return StdBuf(); }
// Append null
if (fAppendNull)
*pOut = '\0';
// Shrink, if less characters were read
OutBuf.Shrink(iLength);
// Done
return OutBuf;
}
示例8: while
bool C4Record::Rec(int iFrame, const StdBuf &sBuf, C4RecordChunkType eType) {
// filler chunks (this should never be necessary, though)
while (iFrame > iLastFrame + 0xff)
Rec(iLastFrame + 0xff, StdBuf(), RCT_Frame);
// get frame difference
uint32_t iFrameDiff = Max<uint32_t>(0, iFrame - iLastFrame);
iLastFrame += iFrameDiff;
// create head
C4RecordChunkHead Head = {static_cast<uint8_t>(iFrameDiff),
static_cast<uint8_t>(eType)};
// pack
CtrlRec.Write(&Head, sizeof(Head));
CtrlRec.Write(sBuf.getData(), sBuf.getSize());
#ifdef IMMEDIATEREC
// immediate rec: always flush
CtrlRec.Flush();
#endif
// Stream
if (fStreaming) Stream(Head, sBuf);
return true;
}
示例9: sizeof
void C4Record::Stream(const C4RecordChunkHead &Head, const StdBuf &sBuf) {
if (!fStreaming) return;
StreamingData.Append(&Head, sizeof(Head));
StreamingData.Append(sBuf.getData(), sBuf.getSize());
}