7#include <range/v3/algorithm/copy.hpp>
40 const auto* first =
reinterpret_cast<const std::byte*
>(&data);
43 return ByteVector{first, first +
sizeof(data)};
49 return reinterpret_cast<const T*
>(data.data());
54 constexpr std::size_t VALUE_SIZE =
sizeof(
typename T::value_type);
55 const std::size_t size = std::size(range) * VALUE_SIZE;
58 for (
auto it = result.
begin();
const auto& elem : range) {
75 requires std::is_arithmetic_v<T> || std::same_as<T, std::timespec> || std::is_pointer_v<T> ||
76 std::is_bounded_array_v<T> || (std::is_aggregate_v<T> && !std::is_array_v<T>)
80 const auto raw_data =
TRY(mio.read_block_impl(address,
sizeof(T)));
82 return raw_data.bit_cast_to<T>();
92 auto is_null_term = [](std::byte chr) {
return std::to_integer<char>(chr) ==
'\0'; };
93 const auto raw_data =
TRY(mio.read_until(address, is_null_term));
95 return data_to_str(raw_data);
101 raw_data.push_back(
static_cast<std::byte
>(
'\0'));
109template <std::
size_t Length>
113 const auto raw_data =
TRY(mio.read_block_impl(address, Length));
Definition byte_vector.hpp:32
auto begin()
Definition byte_vector.hpp:84
Range to_range() const
T should be a stdlib-compatible container type where std::byte is convertible to T::value_type.
Definition byte_vector.hpp:117
static ByteVector from(const Range &range)
Definition byte_vector.hpp:142
std::variant wrapper for a partial implementation of C++23's expected type
Definition expected.hpp:34
Base class for interacting with a tracee's memory in a variety of ways at a (relatively) high-level F...
Definition memory_io_base.hpp:23
#define TRY(val)
If the supplied argument is an error (unexpected) type, then propegate it up the call stack....
Definition error_types.hpp:46
ByteVector reinterpret_raw(const T &data)
Definition memory_io_serde.hpp:38
ByteVector reinterpret_raw_each(const T &range)
Definition memory_io_serde.hpp:53
Definition asm_buffer.hpp:19
static ByteVector to_bytes(const ByteVector &data)
Definition memory_io_serde.hpp:70
static ByteVector to_bytes(const NonTermString< Length > &data)
Definition memory_io_serde.hpp:118
static Result< NonTermString< Length > > read(std::uintptr_t address, MemoryIOBase &mio)
Definition memory_io_serde.hpp:112
static Result< T > read(std::uintptr_t address, MemoryIOBase &mio)
Definition memory_io_serde.hpp:79
static ByteVector to_bytes(const T &data)
Definition memory_io_serde.hpp:85
static ByteVector to_bytes(const std::string &data)
Definition memory_io_serde.hpp:98
static std::string data_to_str(const ByteVector &data)
Definition memory_io_serde.hpp:106
static Result< std::string > read(std::uintptr_t address, MemoryIOBase &mio)
Definition memory_io_serde.hpp:91
Example class implementation:
Definition memory_io_serde.hpp:31
Definition non_terminated_str.hpp:10
static constexpr auto LENGTH
Definition non_terminated_str.hpp:12
const char * string
Definition non_terminated_str.hpp:11