js8call/jsc.h

35 lines
1.0 KiB
C
Raw Normal View History

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>
typedef QMap<QString, int> CompressionMap; // Map(Word, I) where I is the word index sorted by frequency
typedef QList<QString> CompressionList; // List(Word) where list is sorted
typedef QPair<CompressionMap, CompressionList> CompressionTable; // Tuple(Map, List)
typedef QPair<QVector<bool>, int> CodewordPair; // Tuple(Codeword, N) where N = number of characters
typedef QVector<bool> Codeword;
class JSC
{
public:
2018-09-30 22:50:31 -04:00
static CompressionTable loadCompressionTable();
2018-09-30 17:17:47 -04:00
static CompressionTable loadCompressionTable(QTextStream &stream);
static QList<CodewordPair> compress(CompressionTable table, QString text);
static QString decompress(CompressionTable table, Codeword const& bits);
2018-09-30 22:50:31 -04:00
static const int size = 233638;
static char const* map[];
static char const* list[];
2018-09-30 17:17:47 -04:00
};
#endif // JSC_H