本文整理汇总了C++中StreamBuffer::consume方法的典型用法代码示例。如果您正苦于以下问题:C++ StreamBuffer::consume方法的具体用法?C++ StreamBuffer::consume怎么用?C++ StreamBuffer::consume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamBuffer
的用法示例。
在下文中一共展示了StreamBuffer::consume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int, char const* const*)
{
try
{
using libember::util::StreamBuffer;
StreamBuffer<unsigned short, 256> testStream;
for (unsigned int i = 0; i < 1000; ++i)
{
{
unsigned short writeBuffer[7];
for (unsigned int j = 0; j < 7; ++j)
{
writeBuffer[j] = static_cast<unsigned short>(i * 7 + j);
}
unsigned short const* const begin = writeBuffer;
unsigned short const* const end = writeBuffer + sizeof(writeBuffer) / sizeof(writeBuffer[0]);
testStream.append(begin, end);
}
for (unsigned int j = 0; j < 5; ++j)
{
unsigned short const current = testStream.front();
testStream.consume();
if (current != (i * 5 + j))
{
THROW_TEST_EXCEPTION("Invalid head of buffer! Expected " << (i * 5 + j) << ", found " << current);
}
}
std::size_t const size = testStream.size();
if (size != 2 * (i + 1))
{
THROW_TEST_EXCEPTION("Invalid size of buffer! Expected " << ((i + 1) * 2) << ", found " << size);
}
}
for (unsigned int i = 0; i < 1000; ++i)
{
for (unsigned int j = 0; j < 2; ++j)
{
unsigned short const current = testStream.front();
testStream.consume();
if (current != (5000 + i * 2 + j))
{
THROW_TEST_EXCEPTION("Invalid head of buffer! Expected " << ((i + 1000) * 5 + j) << ", found " << current);
}
}
}
}
catch (std::exception const& e)
{
std::cerr << "ERROR: " << e.what() << std::endl;
return 1;
}
return 0;
}