forked from KoynovStas/QCRC_Calc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrc_calc_for_text.h
96 lines (52 loc) · 2.19 KB
/
crc_calc_for_text.h
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef CRC_CALC_FOR_TEXT_H
#define CRC_CALC_FOR_TEXT_H
#include <QObject>
#include <QList>
#include <QByteArray>
#include "qucrc_t.h"
#include "qexecthread.h"
class CRC_Calc_for_Text : public QObject
{
Q_OBJECT
public:
enum EndLineFormat
{
EndLine_LF = 0, // LF: Multics, Unix and Unix-like systems (Linux, OS X, FreeBSD, AIX, Xenix, etc.), BeOS, Amiga, RISC OS,
EndLine_CR, // CR: Commodore 8-bit machines, Acorn BBC, ZX Spectrum, TRS-80, Apple II family, Mac OS up to version 9, and OS-9
EndLine_RS, // RS: QNX pre-POSIX implementation
EndLine_9B, // 0x9B: Atari 8-bit machines using ATASCII variant of ASCII (155 in decimal)
EndLine_CRLF, // CR+LF: Microsoft Windows, DOS (MS-DOS, PC DOS, etc.), DEC TOPS-10, RT-11, CP/M, MP/M, Atari TOS, OS/2
EndLine_LFCR, // LF+CR: Acorn BBC and RISC OS spooled text output
// more see https://en.wikipedia.org/wiki/Newline
};
explicit CRC_Calc_for_Text();
~CRC_Calc_for_Text();
static const QList<QByteArray> Encodings;
bool with_BOM;
EndLineFormat end_line_format;
void set_ucrc(const QuCRC_t *crc) { ucrc = crc; }
size_t get_encoding_index() { return encoding_index; }
int set_encoding_index(size_t new_index);
size_t get_num_lines() { return num_lines; }
size_t get_num_bytes() { return raw_str.size(); }
signals:
void calculated(uint64_t value);
void error(const QString & err);
//signals for inner use
void run_calculate(const QString & data);
public slots:
void calculate(const QString & data);
protected slots:
void _calculate(const QString & data);
private:
const QuCRC_t *ucrc;
QExecThread thread;
size_t encoding_index;
QString tmp_str;
QByteArray raw_str;
size_t num_lines;
void replace_end_line(const QString &data);
void encoding_str();
static const QList<QByteArray> get_Encodings();
};
#endif // CRC_CALC_FOR_TEXT_H