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


C++ StdBuf::getRef方法代码示例

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


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

示例1: if

BOOL C4Playback::ReadBinary(const StdBuf &Buf) {
  // sequential reading: Take over rest from last buffer
  const StdBuf *pUseBuf;
  uint32_t iFrame = 0;
  if (fLoadSequential) {
    sequentialBuffer.Append(Buf);
    pUseBuf = &sequentialBuffer;
    iFrame = iLastSequentialFrame;
  } else
    pUseBuf = &Buf;
  // get buffer data
  size_t iPos = 0;
  bool fFinished = false;
  do {
    // unpack header
    if (pUseBuf->getSize() - iPos < sizeof(C4RecordChunkHead)) break;
    const C4RecordChunkHead *pHead =
        getBufPtr<C4RecordChunkHead>(*pUseBuf, iPos);
    // get chunk
    iPos += sizeof(C4RecordChunkHead);
    StdBuf Chunk = pUseBuf->getPart(iPos, pUseBuf->getSize() - iPos);
    // Create entry
    C4RecordChunk c;
    c.Frame = (iFrame += pHead->iFrm);
    c.Type = pHead->Type;
    // Unpack data
    try {
      // Initialize compiler
      StdCompilerBinRead Compiler;
      Compiler.setInput(Chunk.getRef());
      Compiler.Begin();
      // Read chunk
      switch (pHead->Type) {
        case RCT_Ctrl:
          Compiler.Value(mkPtrAdaptNoNull(c.pCtrl));
          break;
        case RCT_CtrlPkt:
          Compiler.Value(mkPtrAdaptNoNull(c.pPkt));
          break;
        case RCT_End:
          fFinished = true;
          break;
        case RCT_File:
          Compiler.Value(c.Filename);
          Compiler.Value(mkPtrAdaptNoNull(c.pFileData));
          break;
        default:
          // debugrec
          if (pHead->Type >= 0x80) Compiler.Value(mkPtrAdaptNoNull(c.pDbg));
      }
      // Advance over data
      Compiler.End();
      iPos += Compiler.getPosition();
    } catch (StdCompiler::EOFException *pEx) {
      // This is to be expected for sequential reading
      if (fLoadSequential) {
        iPos -= sizeof(C4RecordChunkHead);
        iFrame -= pHead->iFrm;
        delete pEx;
        break;
      }
      LogF("Record: Binary unpack error: %s", pEx->Msg.getData());
      c.Delete();
      delete pEx;
      return FALSE;
    } catch (StdCompiler::Exception *pEx) {
      LogF("Record: Binary unpack error: %s", pEx->Msg.getData());
      c.Delete();
      delete pEx;
      return FALSE;
    }
    // Add to list
    chunks.push_back(c);
    c.pPkt = NULL;
  } while (!fFinished);
  // erase everything but the trailing part from sequential buffer
  if (fLoadSequential) {
    if (iPos >= sequentialBuffer.getSize())
      sequentialBuffer.Clear();
    else if (iPos) {
      sequentialBuffer.Move(iPos, sequentialBuffer.getSize() - iPos);
      sequentialBuffer.Shrink(iPos);
    }
    iLastSequentialFrame = iFrame;
  }
  return TRUE;
}
开发者ID:ev1313,项目名称:clonk-rage,代码行数:87,代码来源:C4Record.cpp


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