forked from qt-creator/qt-creator
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:
@@ -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);
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
@@ -31,7 +31,6 @@
|
|||||||
#include "gdbmihelpers.h"
|
#include "gdbmihelpers.h"
|
||||||
#include "stringutils.h"
|
#include "stringutils.h"
|
||||||
#include "iinterfacepointer.h"
|
#include "iinterfacepointer.h"
|
||||||
#include "base64.h"
|
|
||||||
#include "symbolgroupvalue.h"
|
#include "symbolgroupvalue.h"
|
||||||
#include "extensioncontext.h"
|
#include "extensioncontext.h"
|
||||||
|
|
||||||
|
|||||||
@@ -31,14 +31,13 @@
|
|||||||
#include "outputcallback.h"
|
#include "outputcallback.h"
|
||||||
#include "stringutils.h"
|
#include "stringutils.h"
|
||||||
#include "extensioncontext.h"
|
#include "extensioncontext.h"
|
||||||
#include "base64.h"
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
/* \class OutputCallback
|
/* \class OutputCallback
|
||||||
|
|
||||||
OutputCallback catches DEBUG_OUTPUT_DEBUGGEE and reports it
|
OutputCallback catches DEBUG_OUTPUT_DEBUGGEE and reports it
|
||||||
base64-encoded back to Qt Creator.
|
hex-encoded back to Qt Creator.
|
||||||
\ingroup qtcreatorcdbext
|
\ingroup qtcreatorcdbext
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ SOURCES += qtcreatorcdbextension.cpp \
|
|||||||
stringutils.cpp \
|
stringutils.cpp \
|
||||||
gdbmihelpers.cpp \
|
gdbmihelpers.cpp \
|
||||||
outputcallback.cpp \
|
outputcallback.cpp \
|
||||||
base64.cpp \
|
|
||||||
symbolgroupvalue.cpp \
|
symbolgroupvalue.cpp \
|
||||||
containers.cpp
|
containers.cpp
|
||||||
|
|
||||||
@@ -91,7 +90,6 @@ HEADERS += extensioncontext.h \
|
|||||||
stringutils.h \
|
stringutils.h \
|
||||||
gdbmihelpers.h \
|
gdbmihelpers.h \
|
||||||
outputcallback.h \
|
outputcallback.h \
|
||||||
base64.h \
|
|
||||||
symbolgroupvalue.h \
|
symbolgroupvalue.h \
|
||||||
containers.h \
|
containers.h \
|
||||||
knowntype.h \
|
knowntype.h \
|
||||||
|
|||||||
@@ -59,8 +59,6 @@ QtcLibrary {
|
|||||||
return FileInfo.joinPaths(project.libDirName, dirName);
|
return FileInfo.joinPaths(project.libDirName, dirName);
|
||||||
}
|
}
|
||||||
files: [
|
files: [
|
||||||
"base64.cpp",
|
|
||||||
"base64.h",
|
|
||||||
"common.cpp",
|
"common.cpp",
|
||||||
"common.h",
|
"common.h",
|
||||||
"containers.cpp",
|
"containers.cpp",
|
||||||
|
|||||||
@@ -210,11 +210,9 @@ inline unsigned hexDigit(char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert an ASCII hex digit to its value 'A'->10
|
// 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 v < 10 ? char(v) + '0' : char(v) - 10 + 'a';
|
||||||
return char(v) + '0';
|
|
||||||
return char(v - 10) + 'a';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strings from raw data.
|
// Strings from raw data.
|
||||||
@@ -326,7 +324,7 @@ inline String dataToHexHelper(const unsigned char *p, const unsigned char *end)
|
|||||||
String rc;
|
String rc;
|
||||||
rc.reserve(2 * (end - p));
|
rc.reserve(2 * (end - p));
|
||||||
for ( ; p < 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 / 16));
|
||||||
rc.push_back(toHexDigit(c &0xF));
|
rc.push_back(toHexDigit(c &0xF));
|
||||||
}
|
}
|
||||||
@@ -375,3 +373,9 @@ void formatGdbmiHash(std::ostream &os, const std::map<std::string, std::string>
|
|||||||
if (closeHash)
|
if (closeHash)
|
||||||
os << '}';
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -228,4 +228,7 @@ private:
|
|||||||
// Format a map as a GDBMI hash {key="value",..}
|
// Format a map as a GDBMI hash {key="value",..}
|
||||||
void formatGdbmiHash(std::ostream &os, const std::map<std::string, std::string> &, bool closeHash = true);
|
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
|
#endif // STRINGUTILS_H
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
#include "symbolgroup.h"
|
#include "symbolgroup.h"
|
||||||
#include "symbolgroupvalue.h"
|
#include "symbolgroupvalue.h"
|
||||||
#include "stringutils.h"
|
#include "stringutils.h"
|
||||||
#include "base64.h"
|
|
||||||
#include "containers.h"
|
#include "containers.h"
|
||||||
#include "extensioncontext.h"
|
#include "extensioncontext.h"
|
||||||
|
|
||||||
@@ -1144,7 +1143,7 @@ int SymbolGroupNode::dumpNode(std::ostream &str,
|
|||||||
} else if (dumpParameters.recode(t, aFullIName, ctx, addr, &value, &encoding)) {
|
} else if (dumpParameters.recode(t, aFullIName, ctx, addr, &value, &encoding)) {
|
||||||
str << ",valueencoded=\"" << encoding
|
str << ",valueencoded=\"" << encoding
|
||||||
<< "\",value=\"" << gdbmiWStringFormat(value) <<'"';
|
<< "\",value=\"" << gdbmiWStringFormat(value) <<'"';
|
||||||
} else { // As is: ASCII or base64?
|
} else { // As is: ASCII or hex encoded?
|
||||||
if (isSevenBitClean(value.c_str(), value.size())) {
|
if (isSevenBitClean(value.c_str(), value.size())) {
|
||||||
str << ",valueencoded=\"" << DumpEncodingAscii << "\",value=\""
|
str << ",valueencoded=\"" << DumpEncodingAscii << "\",value=\""
|
||||||
<< gdbmiWStringFormat(value) << '"';
|
<< gdbmiWStringFormat(value) << '"';
|
||||||
|
|||||||
Reference in New Issue
Block a user