Mercurial > dedupe
view FastBitDecoder.hpp @ 115:404795616b1e default tip
Added a lot of common files to ignore
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Sat, 25 Mar 2017 17:43:57 +0100 |
| parents | b9515dc35fe4 |
| children |
line wrap: on
line source
#ifndef FASTBITDECODER_HPP #define FASTBITDECODER_HPP #include "BitArray.hpp" #include <QtCore/QString> #include <QtCore/QMap> class FastBitDecoder { static const size_t N = 256; FastBitDecoder* decoder[N]; unsigned char numBits[N]; QString* data[N]; static unsigned char getPaddedChar(const BitArray& bitArray, uint offset = 0); static BitArray removeFirst(const BitArray& bits); void fill(); void blank(); FastBitDecoder(); void insert(const BitArray& key, const QString& value); uint decode(QString& resString, const BitArray& bits, uint offset) const; public: FastBitDecoder(const QMap<QString, BitArray>& encoder); ~FastBitDecoder(); QString decode(const QString& bits) const; QString decode(const BitArray& bits) const { QString combined; uint n = bits.size(); //Just a qualified overestimate guess on what we will need. combined.reserve(n/4); for (uint decodedBits = 0; decodedBits < n; decodedBits += decode(combined, bits, decodedBits)); combined.squeeze(); return combined; } }; #endif //BITDECODER_HPP
