JS8Call-Improved master
Loading...
Searching...
No Matches
JSC.h
1#ifndef JSC_H
2#define JSC_H
3
7
8#include <QList>
9#include <QMap>
10#include <QPair>
11#include <QStringList>
12#include <QTextStream>
13#include <QVector>
14
15typedef QPair<QVector<bool>, quint32>
16 CodewordPair; // Tuple(Codeword, N) where N = number of characters
17typedef QVector<bool> Codeword; // Codeword bit vector
18
19typedef struct Tuple {
20 char const *str;
21 int size;
22 int index;
23} Tuple;
24
25class JSC {
26 public:
27#if 0
28 static CompressionTable loadCompressionTable();
29 static CompressionTable loadCompressionTable(QTextStream &stream);
30#endif
31 static Codeword codeword(quint32 index, bool separate, quint32 bytesize,
32 quint32 s, quint32 c);
33 static QList<CodewordPair> compress(QString text);
34 static QString decompress(Codeword const &bits);
35
36 static bool exists(QString w, quint32 *pIndex);
37 static quint32 lookup(QString w, bool *ok);
38 static quint32 lookup(char const *b, bool *ok);
39
40 static const quint32 size = 262144;
41 static const Tuple map[262144];
42 static const Tuple list[262144];
43
44 static const quint32 prefixSize = 103;
45 static const Tuple prefix[103];
46};
47
48#endif // JSC_H
Definition JSC.h:25
static Codeword codeword(quint32 index, bool separate, quint32 bytesize, quint32 s, quint32 c)
Generates a codeword for the given index and parameters.
Definition JSC.cpp:43
static quint32 lookup(QString w, bool *ok)
Looks up the index of the given word in the compression map.
Definition JSC.cpp:226
static bool exists(QString w, quint32 *pIndex)
Checks if the given word exists in the compression map.
Definition JSC.cpp:211
static QList< CodewordPair > compress(QString text)
Compresses the given text into a list of codeword pairs.
Definition JSC.cpp:71
static QString decompress(Codeword const &bits)
Decompresses the given bit vector into a string.
Definition JSC.cpp:127
Definition qpriorityqueue.h:39
Definition JSC.h:19