Wireshark 5.1.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
byte_view_text_cells.h
Go to the documentation of this file.
1
12
13#ifndef BYTE_VIEW_TEXT_CELLS_H
14#define BYTE_VIEW_TEXT_CELLS_H
15
16#include <config.h>
17
18#include <QByteArray>
19#include <QString>
20#include <QVector>
21
35class ByteViewTextCells
36{
37public:
44
51
53 struct Cell {
54 int start;
55 int length;
57 QString text;
58 };
59
66 static const int max_cell_bytes = 32;
67
68 ByteViewTextCells();
69
75 void decode(const QByteArray &data, Encoding encoding);
76
78 void clear();
79
81 int cellCount() const;
82
87 Cell cellAt(int cell_index) const;
88
94 int cellIndexForByte(int offset) const;
95
102 bool cellForByte(int offset, Cell &cell) const;
103
104private:
106 struct StoredCell {
107 int start;
108 int text_pos;
109 uint16_t length;
110 uint16_t text_len;
111 uint8_t kind;
112 };
113
115 struct CodePoint {
116 int start;
117 int length;
118 uint32_t uc;
119 };
120
121 Cell singleByteCell(int offset) const;
122
123 void decodeUtf8();
124
126 void appendRun(const QVector<CodePoint> &run);
127
129 void appendCluster(const QVector<CodePoint> &run, int first, int last);
130
132 void appendCodePoints(const QVector<CodePoint> &run, int first, int last);
133
134 void appendCell(int start, int length, CellKind kind, const QString &text);
135 void appendDotCell(int start, int length, CellKind kind);
136
137 static bool isDisplayable(uint32_t uc);
138 static bool isMark(uint32_t uc);
139 static QString textFor(const QVector<CodePoint> &run, int first, int last);
140
141 QByteArray data_;
142 Encoding encoding_;
143 QVector<StoredCell> cells_;
144 QString text_;
145};
146
147#endif // BYTE_VIEW_TEXT_CELLS_H
Encoding
Character encoding of the data.
Definition byte_view_text_cells.h:39
@ Ascii
Definition byte_view_text_cells.h:40
@ Ebcdic
Definition byte_view_text_cells.h:41
@ Utf8
Definition byte_view_text_cells.h:42
static const int max_cell_bytes
Longest run of bytes kept as a single cell.
Definition byte_view_text_cells.h:66
void decode(const QByteArray &data, Encoding encoding)
Replace the cells with a decoding of data.
Definition byte_view_text_cells.cpp:34
CellKind
How a cell is displayed.
Definition byte_view_text_cells.h:46
@ Invalid
Definition byte_view_text_cells.h:49
@ Printable
Definition byte_view_text_cells.h:47
@ NonPrintable
Definition byte_view_text_cells.h:48
void clear()
Remove all cells.
Definition byte_view_text_cells.cpp:45
int cellIndexForByte(int offset) const
Return the index of the cell that contains offset.
Definition byte_view_text_cells.cpp:75
Cell cellAt(int cell_index) const
Return the cell at cell_index.
Definition byte_view_text_cells.cpp:60
int cellCount() const
Definition byte_view_text_cells.cpp:52
bool cellForByte(int offset, Cell &cell) const
Return the cell that contains offset.
Definition byte_view_text_cells.cpp:90
One displayed unit of text and the bytes it stands for.
Definition byte_view_text_cells.h:53
CellKind kind
Definition byte_view_text_cells.h:56
int start
Definition byte_view_text_cells.h:54
int length
Definition byte_view_text_cells.h:55
QString text
Definition byte_view_text_cells.h:57