2018-09-30 17:17:47 -04:00
|
|
|
#ifndef JSC_H
|
|
|
|
#define JSC_H
|
|
|
|
|
|
|
|
/**
|
|
|
|
* (C) 2018 Jordan Sherer <kn4crd@gmail.com> - All Rights Reserved
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include <QTextStream>
|
|
|
|
#include <QList>
|
2018-09-30 22:50:31 -04:00
|
|
|
#include <QStringList>
|
2018-09-30 17:17:47 -04:00
|
|
|
#include <QMap>
|
|
|
|
#include <QPair>
|
|
|
|
#include <QVector>
|
|
|
|
|
2018-10-01 09:57:37 -04:00
|
|
|
typedef QPair<QVector<bool>, quint32> CodewordPair; // Tuple(Codeword, N) where N = number of characters
|
|
|
|
typedef QVector<bool> Codeword; // Codeword bit vector
|
|
|
|
|
2018-10-02 18:03:15 -04:00
|
|
|
typedef struct Tuple{
|
|
|
|
char const * str;
|
|
|
|
int size;
|
|
|
|
int index;
|
|
|
|
} Tuple;
|
2018-09-30 17:17:47 -04:00
|
|
|
|
|
|
|
class JSC
|
|
|
|
{
|
|
|
|
public:
|
2018-10-01 09:57:37 -04:00
|
|
|
#if 0
|
2018-09-30 22:50:31 -04:00
|
|
|
static CompressionTable loadCompressionTable();
|
2018-09-30 17:17:47 -04:00
|
|
|
static CompressionTable loadCompressionTable(QTextStream &stream);
|
2018-10-01 09:57:37 -04:00
|
|
|
#endif
|
|
|
|
static Codeword codeword(quint32 index, bool separate, quint32 bytesize, quint32 s, quint32 c);
|
|
|
|
static QList<CodewordPair> compress(QString text);
|
|
|
|
static QString decompress(Codeword const& bits);
|
|
|
|
|
2018-12-30 20:18:35 -05:00
|
|
|
static bool exists(QString w, quint32 *pIndex);
|
2018-10-01 09:57:37 -04:00
|
|
|
static quint32 lookup(QString w, bool *ok);
|
|
|
|
static quint32 lookup(char const* b, bool *ok);
|
2018-09-30 22:50:31 -04:00
|
|
|
|
2018-10-06 01:43:47 -04:00
|
|
|
static const quint32 size = 262144;
|
|
|
|
static const Tuple map[262144];
|
|
|
|
static const Tuple list[262144];
|
|
|
|
|
2018-10-08 15:36:09 -04:00
|
|
|
static const quint32 prefixSize = 69;
|
|
|
|
static const Tuple prefix[69];
|
2018-09-30 17:17:47 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // JSC_H
|