13#include "DebugServer2/Utils/CompilerSupport.h"
14#include "DebugServer2/Utils/Log.h"
15#include "DebugServer2/Types.h"
24static inline char NibbleToHex(uint8_t
byte) {
25 return "0123456789abcdef"[
byte & 0x0f];
28static inline uint8_t HexToNibble(
char ch) {
29 if (ch >=
'0' && ch <=
'9')
31 else if (ch >=
'a' && ch <=
'f')
33 else if (ch >=
'A' && ch <=
'F')
38static inline uint8_t HexToByte(
char const *chars) {
39 return (HexToNibble(chars[0]) << 4) | HexToNibble(chars[1]);
42template <
typename T>
static inline std::string ToHex(T
const &vec) {
45 result += NibbleToHex(n >> 4);
46 result += NibbleToHex(n & 0x0f);
51static inline ByteVector HexToByteVector(std::string
const &str) {
53 DS2ASSERT(str.size() % 2 == 0);
54 for (
size_t n = 0; n < str.size(); n += 2) {
55 result.emplace_back(HexToByte(&str[n]));
60static inline std::string HexToString(std::string
const &str) {
62 DS2ASSERT(str.size() % 2 == 0);
63 for (
size_t n = 0; n < str.size(); n += 2) {
64 result +=
static_cast<char>(HexToByte(&str[n]));