From 2eed41b6dfb49e7d24d92503203370b7e9053f19 Mon Sep 17 00:00:00 2001 From: hjk <qtc-committer@nokia.com> Date: Tue, 6 Oct 2009 10:17:36 +0200 Subject: [PATCH] debugger: make stringFromByte local --- src/shared/trk/trkutils.cpp | 52 ++++++++++++++++++------------------- src/shared/trk/trkutils.h | 2 -- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/src/shared/trk/trkutils.cpp b/src/shared/trk/trkutils.cpp index a45084bb8cd..7d31f586ff4 100644 --- a/src/shared/trk/trkutils.cpp +++ b/src/shared/trk/trkutils.cpp @@ -36,6 +36,32 @@ namespace trk { +// FIXME: Use the QByteArray based version below? +QString stringFromByte(byte c) +{ + return QString("%1 ").arg(c, 2, 16, QChar('0')); +} + +QString stringFromArray(const QByteArray &ba, int maxLen) +{ + QString str; + QString ascii; + const int size = maxLen == -1 ? ba.size() : qMin(ba.size(), maxLen); + for (int i = 0; i < size; ++i) { + //if (i == 5 || i == ba.size() - 2) + // str += " "; + int c = byte(ba.at(i)); + str += QString("%1 ").arg(c, 2, 16, QChar('0')); + if (i >= 8 && i < ba.size() - 2) + ascii += QChar(c).isPrint() ? QChar(c) : QChar('.'); + } + if (size != ba.size()) { + str += "..."; + ascii += "..."; + } + return str + " " + ascii; +} + QByteArray hexNumber(uint n, int digits) { QByteArray ba = QByteArray::number(n, 16); @@ -235,32 +261,6 @@ QByteArray encode7d(const QByteArray &ba) return res; } -// FIXME: Use the QByteArray based version below? -QString stringFromByte(byte c) -{ - return QString("%1 ").arg(c, 2, 16, QChar('0')); -} - -QString stringFromArray(const QByteArray &ba, int maxLen) -{ - QString str; - QString ascii; - const int size = maxLen == -1 ? ba.size() : qMin(ba.size(), maxLen); - for (int i = 0; i < size; ++i) { - //if (i == 5 || i == ba.size() - 2) - // str += " "; - int c = byte(ba.at(i)); - str += QString("%1 ").arg(c, 2, 16, QChar('0')); - if (i >= 8 && i < ba.size() - 2) - ascii += QChar(c).isPrint() ? QChar(c) : QChar('.'); - } - if (size != ba.size()) { - str += "..."; - ascii += "..."; - } - return str + " " + ascii; -} - void appendByte(QByteArray *ba, byte b) { ba->append(b); diff --git a/src/shared/trk/trkutils.h b/src/shared/trk/trkutils.h index a57ec750f6d..e8388356c53 100644 --- a/src/shared/trk/trkutils.h +++ b/src/shared/trk/trkutils.h @@ -78,8 +78,6 @@ uint extractInt(const char *data); QString quoteUnprintableLatin1(const QByteArray &ba); -// produces "xx " -QString stringFromByte(byte c); // produces "xx xx xx " QString stringFromArray(const QByteArray &ba, int maxLen = - 1); -- GitLab