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


C++ In::read方法代码示例

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


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

示例1: append

void MessageQueue::append(In& stream)
{
  unsigned usedSize,
           numberOfMessages;
  stream >> usedSize >> numberOfMessages;
  // Trying a direct copy. This is hacked, but fast.
  char* dest = numberOfMessages == (unsigned) -1 ? 0 : queue.reserve(usedSize - MessageQueueBase::headerSize);
  if(dest)
  {
    stream.read(dest - MessageQueueBase::headerSize, usedSize);
    queue.numberOfMessages += numberOfMessages;
    queue.usedSize += usedSize;
    queue.writePosition = 0;
  }
  else // Not all messages fit in there, so try step by step (some will be missing).
    for(unsigned i = 0; numberOfMessages == (unsigned) -1 ? !stream.eof() : i < numberOfMessages ; ++i)
    {
      unsigned char id = 0;
      unsigned int size = 0;
      stream >> id;
      stream.read(&size, 3);
      char* dest = numberOfMessages != (unsigned) -1 || id < numOfDataMessageIDs ? queue.reserve(size) : 0;
      if(dest)
      {
        stream.read(dest, size);
        out.finishMessage(MessageID(id));
      }
      else
        stream.skip(size);
    }
}
开发者ID:uchile,项目名称:bh-motion_ros-pkg,代码行数:31,代码来源:MessageQueue.cpp

示例2: transfer

 void transfer(In& in, cyclic_buffer<capacity>& buf) {
     if (!buf.isFull()) {
         size_t availSpace = std::min(buf.availableSpace(), TRANSFER_CHUNK_SIZE);
         char buffer[TRANSFER_CHUNK_SIZE];
         size_t numRead = in.read(buffer, availSpace);
         buf.write(buffer, numRead);
     }
 }
开发者ID:arthur-samarin,项目名称:os,代码行数:8,代码来源:rshd.cpp

示例3: append

void MessageQueue::append(In& stream)
{
  unsigned usedSize,
           numberOfMessages;
  stream >> usedSize >> numberOfMessages;
  // Trying a direct copy. This is hacked, but fast.
  char* dest = numberOfMessages == (unsigned) -1 ? 0 : queue.reserve(usedSize - MessageQueueBase::headerSize);
  if(dest)
  {
    stream.read(dest - MessageQueueBase::headerSize, usedSize);
    queue.numberOfMessages += numberOfMessages;
    queue.usedSize += usedSize;
    queue.writePosition = 0;
  }
  else // Not all messages fit in there, so try step by step (some will be missing).
    for(unsigned i = 0; numberOfMessages == (unsigned) -1 ? !stream.eof() : i < numberOfMessages ; ++i)
    {
      unsigned char id = 0;
      unsigned int size = 0;
      stream >> id;

      stream.read(&size, 3);

      if((id >= numOfDataMessageIDs || size == 0) &&  numberOfMessages == (unsigned) -1)
      {
        OUTPUT(idText, text, "MessageQueue: Logfile appears to be broken. Skipping rest of file. Read messages: " << queue.numberOfMessages << " read size:" << queue.usedSize);
        break;
      }

      char* dest = numberOfMessages != (unsigned) -1 || id < numOfDataMessageIDs ? queue.reserve(size) : 0;
      if(dest)
      {
        stream.read(dest, size);
        out.finishMessage(MessageID(id));
      }
      else
        stream.skip(size);
    }
}
开发者ID:Bigshan,项目名称:BHuman2013,代码行数:39,代码来源:MessageQueue.cpp


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