source: icGREP/icgrep-devel/icgrep/lz4FrameDecoder.h @ 5842

Last change on this file since 5842 was 5422, checked in by cameron, 2 years ago

lz4d - LZ4 decompressor - initial check-in

File size: 1.1 KB
Line 
1/*
2 *  Copyright (c) 2017 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#include <cassert>
8#include <string>
9
10/**
11 * Only works on little-endian architectures for now.
12 * Does not support multi-frame files (streams) (optional in the spec).
13 * Checksums are always ignored.
14 */
15class LZ4FrameDecoder {
16public:
17    LZ4FrameDecoder(const std::string & filename);
18
19    size_t getBlocksStart() const {
20        assert(mValid && "Invalid LZ4 frame.");
21        return mBlocksStart;
22    }
23
24    size_t getBlocksLength() const {
25        assert(mValid && "Invalid LZ4 frame.");
26        return mBlocksLength;
27    }
28
29    bool hasBlockChecksum() const {
30        assert(mValid && "Invalid LZ4 frame.");
31        return mHasBlockChecksum;
32    }
33
34    bool isValid() const {
35        return mValid;
36    }
37
38private:
39    bool mValid = false;
40    size_t mFilesize;
41    size_t mBlocksStart;
42    size_t mBlocksLength;
43    size_t mFDLength;
44    bool mHasContentChecksum;
45    bool mHasBlockChecksum;
46
47    bool decodeFrameDescriptor(std::ifstream & f);
48};
Note: See TracBrowser for help on using the repository browser.