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


C++ MemChunk::getUint64LE方法代码示例

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


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

示例1: parseBlock

void Xz::parseBlock(const MemChunk& chunk, unsigned int& processed, unsigned int size, unsigned char checkMethod, uint64_t& unpaddedSize, uint64_t& uncompressedSize)
{
    std::vector<Filter> filters;
    uint64_t compressedSize;
    bool hasCompressedSize;
    uint64_t decompressedSize;
    bool hasDecompressedSize;

    unsigned int blockHeaderStart = processed;
    this->parseBlockHeader(chunk, processed, size, filters, compressedSize, hasCompressedSize, decompressedSize, hasDecompressedSize);


    unsigned int blockStart = processed;
    MemChunk tmpChunk;
    for (auto& filter : filters)
    {
        switch (filter.mId)
        {
        case 0x21:
            {
            unsigned int compSize = this->decodeLzma2(chunk, tmpChunk, processed, size, filter);
            if (hasCompressedSize && compressedSize != compSize)
                Except::reportError(blockStart, "xz, block", "compressed size field does not match actual size");
            break;
            }
        default:
            Except::reportError(filter.mPos, "xz, filter", "unsupported filter");
        }
    }

    if (hasDecompressedSize && decompressedSize != tmpChunk.size())
        Except::reportError(blockStart, "xz, block", "decompressed size field does not match actual size");
    uncompressedSize = tmpChunk.size();

    mSrcColorizer.addHighlight(blockStart, processed - blockStart, QColor(192, 192, 192, 64));
    mDecompChunk.append(tmpChunk);

    mSrcColorizer.addSeparation(processed, 2);
    unsigned int padding = this->checkPadding(chunk, processed, size, "xz, block padding");

    switch (checkMethod)
    {
    case 0x00: // none
        break;
    case 0x01: // CRC32
        if (!Util::checkRange(processed, 4, size))
            Except::reportError(size, "xz, block check", "unexpected end of data");
        if (chunk.getUint32LE(processed) != Hasher::getCRC32(tmpChunk))
            Except::reportError(processed, "xz, block check", "invalid check");

        mSrcColorizer.addHighlight(processed, 4, QColor(0, 255, 0, 64));
        processed += 4;
        mSrcColorizer.addSeparation(processed, 2);
        break;
    case 0x04: // CRC64
        if (!Util::checkRange(processed, 8, size))
            Except::reportError(size, "xz, block check", "unexpected end of data");
        if (chunk.getUint64LE(processed) != Hasher::getCRC64(tmpChunk))
            Except::reportError(processed, "xz, block check", "invalid check");

        mSrcColorizer.addHighlight(processed, 8, QColor(0, 255, 0, 64));
        processed += 8;
        mSrcColorizer.addSeparation(processed, 2);
        break;
    case 0x0A: // SHA-256
        if (!Util::checkRange(processed, 32, size))
            Except::reportError(size, "xz, block check", "unexpected end of data");
        if (chunk.subChunk(processed, 32) != Hasher::getSha256(tmpChunk).chunk())
            Except::reportError(processed, "xz, block check", "invalid check");

        mSrcColorizer.addHighlight(processed, 32, QColor(0, 255, 0, 64));
        processed += 32;
        mSrcColorizer.addSeparation(processed, 2);
        break;
    default:
        Except::reportError(processed, "xz, block check", "unknown check method");
    }

    unpaddedSize = processed - blockHeaderStart - padding;
}
开发者ID:gendx,项目名称:tyrex,代码行数:80,代码来源:xz.cpp


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