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

Last change on this file since 5849 was 5849, checked in by xwa163, 7 months ago

Fix bug of lz4FrameDecoder

File size: 1.2 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#ifndef LZ4_FRAME_DECODER_H
8#define LZ4_FRAME_DECODER_H
9
10#include <cassert>
11#include <string>
12
13/**
14 * Only works on little-endian architectures for now.
15 * Does not support multi-frame files (streams) (optional in the spec).
16 * Checksums are always ignored.
17 */
18class LZ4FrameDecoder {
19public:
20    LZ4FrameDecoder(const std::string & filename);
21
22    size_t getBlocksStart() const {
23        assert(mValid && "Invalid LZ4 frame.");
24        return mBlocksStart;
25    }
26
27    size_t getBlocksLength() const {
28        assert(mValid && "Invalid LZ4 frame.");
29        return mBlocksLength;
30    }
31
32    bool hasBlockChecksum() const {
33        assert(mValid && "Invalid LZ4 frame.");
34        return mHasBlockChecksum;
35    }
36
37    bool isValid() const {
38        return mValid;
39    }
40
41private:
42    bool mValid = false;
43    size_t mFilesize;
44    size_t mBlocksStart;
45    size_t mBlocksLength;
46    size_t mFDLength;
47    bool mHasContentChecksum;
48    bool mHasBlockChecksum;
49
50    bool decodeFrameDescriptor(std::ifstream & f);
51};
52
53#endif
Note: See TracBrowser for help on using the repository browser.