File: jsc.h

package info (click to toggle)
js8call 2.2.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 22,416 kB
  • sloc: cpp: 563,285; f90: 9,265; ansic: 937; python: 132; sh: 93; makefile: 6
file content (47 lines) | stat: -rw-r--r-- 1,227 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef JSC_H
#define JSC_H

/**
 * (C) 2018 Jordan Sherer <kn4crd@gmail.com> - All Rights Reserved
 **/

#include <QTextStream>
#include <QList>
#include <QStringList>
#include <QMap>
#include <QPair>
#include <QVector>

typedef QPair<QVector<bool>, quint32> CodewordPair;        // Tuple(Codeword, N) where N = number of characters
typedef QVector<bool> Codeword;                        // Codeword bit vector

typedef struct Tuple{
    char const * str;
    int size;
    int index;
} Tuple;

class JSC
{
public:
#if 0
    static CompressionTable loadCompressionTable();
    static CompressionTable loadCompressionTable(QTextStream &stream);
#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);

    static bool exists(QString w, quint32 *pIndex);
    static quint32 lookup(QString w, bool *ok);
    static quint32 lookup(char const* b, bool *ok);

    static const quint32 size = 262144;
    static const Tuple map[262144];
    static const Tuple list[262144];

    static const quint32 prefixSize = 103;
    static const Tuple prefix[103];
};

#endif // JSC_H