本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}