1 /* data_printer.h 2 * 3 * Used by ByteView and others, to create data dumps in printable 4 * form 5 * 6 * Wireshark - Network traffic analyzer 7 * By Gerald Combs <gerald@wireshark.org> 8 * Copyright 1998 Gerald Combs 9 * 10 * SPDX-License-Identifier: GPL-2.0-or-later 11 */ 12 13 #ifndef DATA_PRINTER_H 14 #define DATA_PRINTER_H 15 16 #include <config.h> 17 18 #include <QObject> 19 #include <QActionGroup> 20 21 #include <ui/qt/utils/idata_printable.h> 22 23 class DataPrinter : public QObject 24 { 25 Q_OBJECT 26 public: 27 explicit DataPrinter(QObject *parent = 0); 28 29 enum DumpType { 30 DP_HexDump, 31 DP_HexOnly, 32 DP_HexStream, 33 DP_PrintableText, 34 DP_EscapedString, 35 DP_Binary 36 }; 37 38 void toClipboard(DataPrinter::DumpType type, IDataPrintable * printable); 39 40 void setByteLineLength(int); 41 int byteLineLength() const; 42 // Insert a space after this many bytes separatorInterval()43 static int separatorInterval() { return 8; } 44 // The number of hexadecimal characters per line 45 static int hexChars(); 46 47 static QActionGroup * copyActions(QObject * copyClass, QObject * data = Q_NULLPTR); 48 static DataPrinter * instance(); 49 50 protected slots: 51 void copyIDataBytes(bool); 52 53 private: 54 QString hexTextDump(const QByteArray printData, bool showASCII); 55 void binaryDump(const QByteArray printData); 56 57 int byteLineLength_; 58 }; 59 60 #endif // DATA_PRINTER_H 61