Debugger: Merge qtcreatorcdbext/base64.{h,cpp} into stringutils

There was only one function left and this wasn't related to
base64 anymore.

Change-Id: I071fb383bc3d79b606859cbfc79995dd7345a0a5
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
hjk
2015-12-15 09:30:42 +01:00
committed by David Schulz
parent c063ced780
commit 390c633659
9 changed files with 14 additions and 98 deletions

View File

@@ -1,44 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#include "base64.h"
#include <sstream>
static char hexDigit(unsigned char nibble)
{
return nibble < 10 ? '0' + nibble : 'a' + nibble - 10;
}
void hexEncode(std::ostream &str, const unsigned char *source, size_t sourcelen)
{
for (size_t i = 0; i < sourcelen; ++i)
str << hexDigit(source[i] >> 4) << hexDigit(source[i] & 0xf);
}

View File

@@ -1,40 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms and
** conditions see http://www.qt.io/terms-conditions. For further information
** use the contact form at http://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 or version 3 as published by the Free
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
** following information to ensure the GNU Lesser General Public License
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, The Qt Company gives you certain additional
** rights. These rights are described in The Qt Company LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
****************************************************************************/
#ifndef BASE64_H
#define BASE64_H
#include <iosfwd>
#include <string>
// Hex encoding helpers
void hexEncode(std::ostream &str, const unsigned char *source, size_t sourcelen);
#endif // BASE64_H

View File

@@ -31,7 +31,6 @@
#include "gdbmihelpers.h"
#include "stringutils.h"
#include "iinterfacepointer.h"
#include "base64.h"
#include "symbolgroupvalue.h"
#include "extensioncontext.h"

View File

@@ -31,14 +31,13 @@
#include "outputcallback.h"
#include "stringutils.h"
#include "extensioncontext.h"
#include "base64.h"
#include <cstring>
/* \class OutputCallback
OutputCallback catches DEBUG_OUTPUT_DEBUGGEE and reports it
base64-encoded back to Qt Creator.
hex-encoded back to Qt Creator.
\ingroup qtcreatorcdbext
*/

View File

@@ -79,7 +79,6 @@ SOURCES += qtcreatorcdbextension.cpp \
stringutils.cpp \
gdbmihelpers.cpp \
outputcallback.cpp \
base64.cpp \
symbolgroupvalue.cpp \
containers.cpp
@@ -91,7 +90,6 @@ HEADERS += extensioncontext.h \
stringutils.h \
gdbmihelpers.h \
outputcallback.h \
base64.h \
symbolgroupvalue.h \
containers.h \
knowntype.h \

View File

@@ -59,8 +59,6 @@ QtcLibrary {
return FileInfo.joinPaths(project.libDirName, dirName);
}
files: [
"base64.cpp",
"base64.h",
"common.cpp",
"common.h",
"containers.cpp",

View File

@@ -210,11 +210,9 @@ inline unsigned hexDigit(char c)
}
// Convert an ASCII hex digit to its value 'A'->10
inline char toHexDigit(unsigned v)
static char toHexDigit(unsigned char v)
{
if (v < 10)
return char(v) + '0';
return char(v - 10) + 'a';
return v < 10 ? char(v) + '0' : char(v) - 10 + 'a';
}
// Strings from raw data.
@@ -326,7 +324,7 @@ inline String dataToHexHelper(const unsigned char *p, const unsigned char *end)
String rc;
rc.reserve(2 * (end - p));
for ( ; p < end ; ++p) {
const unsigned c = *p;
const unsigned char c = *p;
rc.push_back(toHexDigit(c / 16));
rc.push_back(toHexDigit(c &0xF));
}
@@ -375,3 +373,9 @@ void formatGdbmiHash(std::ostream &os, const std::map<std::string, std::string>
if (closeHash)
os << '}';
}
void hexEncode(std::ostream &str, const unsigned char *source, size_t sourcelen)
{
for (size_t i = 0; i < sourcelen; ++i)
str << toHexDigit(source[i] >> 4) << toHexDigit(source[i] & 0xf);
}

View File

@@ -228,4 +228,7 @@ private:
// Format a map as a GDBMI hash {key="value",..}
void formatGdbmiHash(std::ostream &os, const std::map<std::string, std::string> &, bool closeHash = true);
// Hex encoding helpers
void hexEncode(std::ostream &str, const unsigned char *source, size_t sourcelen);
#endif // STRINGUTILS_H

View File

@@ -32,7 +32,6 @@
#include "symbolgroup.h"
#include "symbolgroupvalue.h"
#include "stringutils.h"
#include "base64.h"
#include "containers.h"
#include "extensioncontext.h"
@@ -1144,7 +1143,7 @@ int SymbolGroupNode::dumpNode(std::ostream &str,
} else if (dumpParameters.recode(t, aFullIName, ctx, addr, &value, &encoding)) {
str << ",valueencoded=\"" << encoding
<< "\",value=\"" << gdbmiWStringFormat(value) <<'"';
} else { // As is: ASCII or base64?
} else { // As is: ASCII or hex encoded?
if (isSevenBitClean(value.c_str(), value.size())) {
str << ",valueencoded=\"" << DumpEncodingAscii << "\",value=\""
<< gdbmiWStringFormat(value) << '"';