本文整理汇总了C++中StreamBuffer::resize方法的典型用法代码示例。如果您正苦于以下问题:C++ StreamBuffer::resize方法的具体用法?C++ StreamBuffer::resize怎么用?C++ StreamBuffer::resize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamBuffer
的用法示例。
在下文中一共展示了StreamBuffer::resize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: combine
void StreamBuffer::combine(const std::vector<StreamBuffer>& buffers, StreamBuffer& combined) {
unsigned int totalSize = 0;
for(unsigned int i = 0; i < buffers.size(); i++)
totalSize += buffers[i].size;
combined.resize(totalSize + buffers.size() * sizeof(unsigned int) + 1);
unsigned int offset = 0;
assert(buffers.size() < 0xFF);
combined.buffer[offset++] = buffers.size();
for(unsigned int i = 0; i < buffers.size(); i++) {
unsigned int *pieceSize = (unsigned int*)(combined.buffer + offset);
*pieceSize = buffers[i].size;
offset += sizeof(unsigned int);
memcpy(combined.buffer + offset, buffers[i].buffer, buffers[i].size);
offset += buffers[i].size;
}
combined.size = offset;
}