forked from qt-creator/qt-creator
Implement basics for edit value handling in CDB.
- Add routine for formatting edit values. - Optionally store memory in SymbolGroupNode (along with special info) to be able to re-use it for edit values using a simple convenience class MemoryHandle. - Prototypically implement QString and QByteArray / Qt 5. Task-number: QTCREATORBUG-8344 Change-Id: I6d2cac7a1e9ac48e94335142c41dc1bfb984c515 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
@@ -27,6 +27,10 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef _SCL_SECURE_NO_WARNINGS // silence std::string::copy
|
||||
# define _SCL_SECURE_NO_WARNINGS
|
||||
#endif
|
||||
|
||||
#include "stringutils.h"
|
||||
|
||||
#include <cctype>
|
||||
@@ -285,12 +289,29 @@ void decodeHex(const char *p, const char *end, unsigned char *target)
|
||||
}
|
||||
}
|
||||
|
||||
std::wstring dataToHexW(const unsigned char *p, const unsigned char *end)
|
||||
MemoryHandle *MemoryHandle::fromStdString(const std::string &s)
|
||||
{
|
||||
const size_t size = s.size();
|
||||
unsigned char *data = new unsigned char[size];
|
||||
s.copy(reinterpret_cast<char *>(data), size);
|
||||
return new MemoryHandle(data, size);
|
||||
}
|
||||
|
||||
MemoryHandle *MemoryHandle::fromStdWString(const std::wstring &ws)
|
||||
{
|
||||
const size_t size = ws.size();
|
||||
wchar_t *data = new wchar_t[size];
|
||||
ws.copy(data, size);
|
||||
return new MemoryHandle(data, size);
|
||||
}
|
||||
|
||||
template <class String>
|
||||
inline String dataToHexHelper(const unsigned char *p, const unsigned char *end)
|
||||
{
|
||||
if (p == end)
|
||||
return std::wstring();
|
||||
return String();
|
||||
|
||||
std::wstring rc;
|
||||
String rc;
|
||||
rc.reserve(2 * (end - p));
|
||||
for ( ; p < end ; ++p) {
|
||||
const unsigned c = *p;
|
||||
@@ -300,6 +321,16 @@ std::wstring dataToHexW(const unsigned char *p, const unsigned char *end)
|
||||
return rc;
|
||||
}
|
||||
|
||||
std::wstring dataToHexW(const unsigned char *p, const unsigned char *end)
|
||||
{
|
||||
return dataToHexHelper<std::wstring>(p, end);
|
||||
}
|
||||
|
||||
std::string dataToHex(const unsigned char *p, const unsigned char *end)
|
||||
{
|
||||
return dataToHexHelper<std::string>(p, end);
|
||||
}
|
||||
|
||||
// Readable hex: '0xAA 0xBB'..
|
||||
std::wstring dataToReadableHexW(const unsigned char *begin, const unsigned char *end)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user