Commit 2eed41b6 authored by hjk's avatar hjk
Browse files

debugger: make stringFromByte local

parent 751f2f69
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment