3df8d0db9b32c7a83527ad791eb368616403e282
[metze/wireshark/wip.git] / ui / qt / models / packet_list_record.h
1 /* packet_list_record.h
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998 Gerald Combs
6  *
7  * SPDX-License-Identifier: GPL-2.0+*/
8
9 #ifndef PACKET_LIST_RECORD_H
10 #define PACKET_LIST_RECORD_H
11
12 #include <config.h>
13
14 #include <glib.h>
15
16 #include "cfile.h"
17
18 #include <epan/column-info.h>
19 #include <epan/packet.h>
20
21 #include <QByteArray>
22 #include <QList>
23 #include <QVariant>
24
25 struct conversation;
26 struct _GStringChunk;
27
28 class ColumnTextList;
29
30 class PacketListRecord
31 {
32 public:
33     PacketListRecord(frame_data *frameData);
34
35     // Allocate our records using wmem.
36     static void *operator new(size_t size);
37     static void operator delete(void *) {}
38
39     // Return the string value for a column. Data is cached if possible.
40     const QByteArray columnString(capture_file *cap_file, int column, bool colorized = false);
41     frame_data *frameData() const { return fdata_; }
42     // packet_list->col_to_text in gtk/packet_list_store.c
43     static int textColumn(int column) { return cinfo_column_.value(column, -1); }
44     bool colorized() { return colorized_; }
45     struct conversation *conversation() { return conv_; }
46
47     int columnTextSize(const char *str);
48     static void resetColumns(column_info *cinfo);
49     void resetColorized();
50     inline int lineCount() { return lines_; }
51     inline int lineCountChanged() { return line_count_changed_; }
52
53     static void clearStringPool();
54
55 private:
56     /** The column text for some columns */
57     ColumnTextList *col_text_;
58
59     frame_data *fdata_;
60     int lines_;
61     bool line_count_changed_;
62     static QMap<int, int> cinfo_column_;
63
64     /** Data versions. Used to invalidate col_text_ */
65     static unsigned col_data_ver_;
66     unsigned data_ver_;
67     /** Has this record been colorized? */
68     bool colorized_;
69
70     /** Conversation. Used by RelatedPacketDelegate */
71     struct conversation *conv_;
72
73     void dissect(capture_file *cap_file, bool dissect_color = false);
74     void cacheColumnStrings(column_info *cinfo);
75
76     static struct _GStringChunk *string_pool_;
77
78 };
79
80 #endif // PACKET_LIST_RECORD_H
81
82 /*
83  * Editor modelines
84  *
85  * Local Variables:
86  * c-basic-offset: 4
87  * tab-width: 8
88  * indent-tabs-mode: nil
89  * End:
90  *
91  * ex: set shiftwidth=4 tabstop=8 expandtab:
92  * :indentSize=4:tabSize=8:noTabs=true:
93  */