33 if (!traits_type::get_size(context, container_addr, space, scratch, size)) {
34 out.write(opts.open_bracket);
35 out.write(opts.close_bracket);
39 out.write(opts.open_bracket);
40 const size_t print_count = size < opts.max_print ? size : opts.max_print;
41 for (
size_t index = 0; index < print_count; ++index) {
43 out.write(opts.entry_separator);
45 uintptr_t element_addr = 0;
46 if (!traits_type::get_element_address(context, container_addr, space, scratch, index, element_addr) ||
47 !traits_type::format_element(context, space, scratch, element_addr, out)) {
53 if (size > opts.max_print) {
54 out.write(opts.entry_separator);
57 out.write(opts.close_bracket);
67 const sink &out)
noexcept {
73 T *value = allocator.allocate<T>();
74 if (!value || !space.read_bytes(element_addr, value,
sizeof(T)))
85template <
typename Tag>
91template <
typename T,
typename RemotePtr,
typename RemoteSize>
93 using pointer_query =
decltype(make_remote_offset_query<uintptr_t, RemotePtr>(0));
94 using size_query =
decltype(make_remote_offset_query<size_t, RemoteSize>(0));
104 span<std::byte>,
size_t &out_size)
noexcept {
105 return context->size(space, container_addr, out_size);
109 span<std::byte>,
size_t &out_capacity)
noexcept {
110 return context->has_capacity && context->capacity(space, container_addr, out_capacity);
115 uintptr_t &out_element_addr)
noexcept {
116 uintptr_t data_address = 0;
117 if (!context->data(space, container_addr, data_address))
119 out_element_addr = data_address + index *
sizeof(T);
124 uintptr_t element_addr,
const sink &out)
noexcept {
125 return detail::format_remote_vector_element<T>(space, scratch, element_addr, out);
130 struct context_type {
135 size_t &out_size)
noexcept {
136 out_size = context->count;
141 span<std::byte>,
size_t index, uintptr_t &out_element_addr)
noexcept {
142 if (index >= context->count)
144 out_element_addr = container_addr + index *
sizeof(T);
149 uintptr_t element_addr,
const sink &out)
noexcept {
150 return detail::format_remote_vector_element<T>(space, scratch, element_addr, out);
157template <
typename T,
typename RemotePtr = u
intptr_t,
typename RemoteSize =
size_t>
158[[nodiscard]]
constexpr auto make_remote_vector(uintptr_t container_addr, ptrdiff_t data_offset, ptrdiff_t size_offset,
159 ptrdiff_t capacity_offset = -1) noexcept {
162 typename traits::context_type context{make_remote_offset_query<uintptr_t, RemotePtr>(data_offset),
163 make_remote_offset_query<size_t, RemoteSize>(size_offset),
164 make_remote_offset_query<size_t, RemoteSize>(capacity_offset),
165 capacity_offset >= 0};
172template <
typename T> [[nodiscard]]
constexpr auto make_remote_carray(uintptr_t array_addr,
size_t count)
noexcept {
Type-erased, two-word handle to a remote address space.
Definition address_space.hpp:204
Owning typed container bound to a compile-time traits dispatcher.
Definition remote_container.hpp:102
Definition remote_object.hpp:231
Zero-allocation bump allocator for scratch buffers.
Definition scratch_allocator.hpp:27
bool format_remote_vector_element(address_space_ref space, span< std::byte > scratch, uintptr_t element_addr, const sink &out) noexcept
Definition remote_vector.hpp:66
constexpr remote_vector< Tag > make_remote_vector(uintptr_t container_addr, typename remote_vector_traits< Tag >::context_type context) noexcept
Definition remote_vector.hpp:87
constexpr auto make_remote_carray(uintptr_t array_addr, size_t count) noexcept
Creates a vector inspector for a fixed-size remote C array.
Definition remote_vector.hpp:172
reloco::sink sink
Type-erased, zero-allocation output sink.
Definition microfmt.hpp:46
Type-erased views and contexts for formatting remote containers.
Reusable callback and typed-offset accessors for remote layouts.
Remote object dumping, layout macros, and string pointer wrappers with 32-bit compatibility support.
Configuration options for formatting container views.
Definition remote_container.hpp:25
Definition remote_vector.hpp:63
Definition remote_vector.hpp:26
typename traits_type::context_type context_type
Definition remote_vector.hpp:28
static bool format(value_ref< const context_type > context, uintptr_t container_addr, const container_options &opts, address_space_ref space, span< std::byte > scratch, const sink &out) noexcept
Definition remote_vector.hpp:30
Definition remote_vector.hpp:62
Traits customization point for remote object metadata.
Definition remote_object.hpp:217
size_t count
Definition remote_vector.hpp:131
static bool get_size(value_ref< const context_type > context, uintptr_t, address_space_ref, span< std::byte >, size_t &out_size) noexcept
Definition remote_vector.hpp:134
static bool format_element(value_ref< const context_type >, address_space_ref space, span< std::byte > scratch, uintptr_t element_addr, const sink &out) noexcept
Definition remote_vector.hpp:148
static bool get_element_address(value_ref< const context_type > context, uintptr_t container_addr, address_space_ref, span< std::byte >, size_t index, uintptr_t &out_element_addr) noexcept
Definition remote_vector.hpp:140
static bool get_capacity(value_ref< const context_type > context, uintptr_t container_addr, address_space_ref space, span< std::byte >, size_t &out_capacity) noexcept
Definition remote_vector.hpp:108
decltype(make_remote_offset_query< size_t, RemoteSize >(0)) size_query
Definition remote_vector.hpp:94
decltype(make_remote_offset_query< uintptr_t, RemotePtr >(0)) pointer_query
Definition remote_vector.hpp:93
static bool get_size(value_ref< const context_type > context, uintptr_t container_addr, address_space_ref space, span< std::byte >, size_t &out_size) noexcept
Definition remote_vector.hpp:103
static bool format_element(value_ref< const context_type >, address_space_ref space, span< std::byte > scratch, uintptr_t element_addr, const sink &out) noexcept
Definition remote_vector.hpp:123
static bool get_element_address(value_ref< const context_type > context, uintptr_t container_addr, address_space_ref space, span< std::byte >, size_t index, uintptr_t &out_element_addr) noexcept
Definition remote_vector.hpp:113
size_query capacity
Definition remote_vector.hpp:99
bool has_capacity
Definition remote_vector.hpp:100
pointer_query data
Definition remote_vector.hpp:97
size_query size
Definition remote_vector.hpp:98
Static customization point for a remote vector implementation.
Definition remote_vector.hpp:22
Definition remote_object.hpp:229