JS8Call-Improved master
Loading...
Searching...
No Matches
JSC.h
Go to the documentation of this file.
1#ifndef JSC_H
2#define JSC_H
3
16
17#include <QList>
18#include <QMap>
19#include <QPair>
20#include <QStringList>
21#include <QTextStream>
22#include <QVector>
23
25 * @typedef CodewordPair
26 * @brief Tuple containing a codeword bit-vector and an associated integer.
27 *
28 * This typedef aliases a `QPair<Codeword, quint32>` and is used to
29 * represent a codeword together with an auxiliary integer value such as
30 * the character count or an index. The first element is the
31 * bit-vector representation and the second is the associated unsigned
32 * integer.
33 */
34typedef QPair<QVector<bool>, quint32> CodewordPair;
35
44typedef QVector<bool> Codeword;
45
49typedef struct Tuple {
50 char const *str;
51 int size;
52 int index;
54
63class JSC {
64 public:
65#if 0
66 static CompressionTable loadCompressionTable();
67 static CompressionTable loadCompressionTable(QTextStream &stream);
68#endif
69
79 static Codeword codeword(quint32 index, bool separate, quint32 bytesize,
80 quint32 s, quint32 c);
81
87 static QList<CodewordPair> compress(QString text);
88
94 static QString decompress(Codeword const &bits);
95
102 static bool exists(QString w, quint32 *pIndex);
103
110 static quint32 lookup(QString w, bool *ok);
111
118 static quint32 lookup(char const *b, bool *ok);
119
120 static const quint32 size = 262144;
121 static const Tuple map[262144];
122 static const Tuple list[262144];
123
124 static const quint32 prefixSize = 103;
125 static const Tuple prefix[103];
126};
127
128#endif // JSC_H
QVector< bool > Codeword
Codeword bit-vector type.
Definition JSC.h:44
QPair< QVector< bool >, quint32 > CodewordPair
Tuple containing a codeword bit-vector and an associated integer.
Definition JSC.h:34
Static compressor/lookup helper for JS8Call.
Definition JSC.h:63
static Codeword codeword(quint32 index, bool separate, quint32 bytesize, quint32 s, quint32 c)
Build a codeword for the given parameters.
Definition JSC.cpp:43
static const Tuple map[262144]
Definition JSC.h:25
static quint32 lookup(QString w, bool *ok)
Lookup a word and return its dictionary index.
Definition JSC.cpp:226
static const quint32 prefixSize
Definition JSC.h:124
static const quint32 size
Definition JSC.h:120
static bool exists(QString w, quint32 *pIndex)
Test whether a word exists in the dictionary.
Definition JSC.cpp:211
static QList< CodewordPair > compress(QString text)
Compress text into a sequence of codewords.
Definition JSC.cpp:71
static const Tuple prefix[103]
Definition JSC.h:262173
static QString decompress(Codeword const &bits)
Decompress a codeword bit-vector into a QString.
Definition JSC.cpp:127
static const Tuple list[262144]
Definition JSC.h:25
Definition qpriorityqueue.h:39
Small mapping tuple used in the static lookup arrays.
Definition JSC.h:49
char const * str
Definition JSC.h:50
int size
Definition JSC.h:51
int index
Definition JSC.h:52