Refactor gdb interface

This commit is contained in:
momo5502
2025-01-17 19:50:06 +01:00
parent 2f6d17fde6
commit b180d9629c
6 changed files with 48 additions and 23 deletions

View File

@@ -1,6 +1,7 @@
#pragma once
#include <string>
#include <ranges>
#include <cstddef>
#include <sstream>
#include <cwctype>
#include <algorithm>
@@ -44,4 +45,27 @@ namespace utils::string
{
return to_lower(std::move(str));
}
template <typename Integer>
requires(std::is_integral_v<Integer>)
std::string to_hex_string(const Integer& i)
{
std::stringstream stream{};
stream << std::hex << i;
return stream.str();
}
inline std::string to_hex_string(const void* data, const size_t size)
{
std::stringstream stream{};
stream << std::hex;
for (size_t i = 0; i < size; ++i)
{
const auto value = static_cast<const uint8_t*>(data)[i];
stream << value;
}
return stream.str();
}
}