本文整理汇总了C++中MemChunk::uncompare方法的典型用法代码示例。如果您正苦于以下问题:C++ MemChunk::uncompare方法的具体用法?C++ MemChunk::uncompare怎么用?C++ MemChunk::uncompare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemChunk
的用法示例。
在下文中一共展示了MemChunk::uncompare方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doParse
void Xz::doParse(const MemChunk& chunk, std::shared_ptr<data::Compress>& data)
{
unsigned int size = chunk.size();
// check initial size
if (size < 6)
Except::reportError(size, "xz, magic", "unexpected end of data");
if (chunk.uncompare(Xz::mMagic, 6))
Except::reportError(0, "xz, magic", "invalid magic");
mSrcColorizer.addHighlight(0, 6, QColor(255, 128, 0, 64));
mSrcColorizer.addSeparation(6, 2);
// check header size
if (size < 12)
Except::reportError(size, "xz, header", "unexpected end of data");
mSrcColorizer.addHighlight(6, 6, QColor(255, 0, 0, 64));
mSrcColorizer.addSeparation(8, 1);
mSrcColorizer.addSeparation(12, 2);
if (chunk[6] || chunk[7] & 0xF0)
Except::reportError(6, "xz, stream flags", "invalid stream flags");
unsigned char checkMethod = chunk[7] & 0x0F;
if (chunk.getUint32LE(8) != Hasher::getCRC32(chunk.subChunk(6, 2)))
Except::reportError(8, "xz, stream flags crc", "invalid crc");
// parse blocks
unsigned int processed = 12;
std::vector<std::pair<uint64_t, uint64_t> > records;
for (;;)
{
if (processed >= size)
Except::reportError(size, "xz, block", "unexpected end of data");
if (chunk[processed] == 0)
break;
uint64_t unpaddedSize, uncompressedSize;
this->parseBlock(chunk, processed, size, checkMethod, unpaddedSize, uncompressedSize);
records.push_back(std::make_pair(unpaddedSize, uncompressedSize));
}
// parse index
unsigned int beginIndex = processed;
this->parseIndex(chunk, processed, size, records);
unsigned int indexSize = processed - beginIndex;
// parse footer
if (!Util::checkRange(processed, 12, size))
Except::reportError(size, "xz, stream footer", "unexpected end of data");
mSrcColorizer.addHighlight(processed, 12, QColor(255, 128, 0, 64));
mSrcColorizer.addSeparation(processed + 4, 1);
mSrcColorizer.addSeparation(processed + 8, 1);
mSrcColorizer.addSeparation(processed + 10, 1);
mSrcColorizer.addSeparation(processed + 12, 2);
if (chunk.getUint32LE(processed) != Hasher::getCRC32(chunk.subChunk(processed + 4, 6)))
Except::reportError(processed, "xz, stream footer", "invalid crc");
unsigned int backwardSize = chunk.getUint32LE(processed + 4);
if (indexSize != (backwardSize + 1) << 2)
Except::reportError(processed + 4, "xz, stream footer", "backward size does not match index size");
if (chunk.subChunk(6, 2) != chunk.subChunk(processed + 8, 2))
Except::reportError(processed + 8, "xz, stream footer", "stream flags don't match header");
if (chunk.uncompare(Xz::mMagicFooter, 2, processed + 10))
Except::reportError(processed + 10, "xz, stream footer", "invalid magic");
data = std::make_shared<data::Compress>(chunk, mDecompChunk, mSrcColorizer, mDecompColorizer);
}