10#include "../microfmt.hpp"
45 span<
char> scratch RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS,
46 size_t max_limit = 4096) noexcept
47 : addr_(addr), space_(space), scratch_(scratch), max_limit_(max_limit) {}
60 char (&scratch RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS)[N],
61 size_t max_limit = 4096) noexcept
62 : addr_(addr), space_(space), scratch_(scratch, N), max_limit_(max_limit) {}
68 [[nodiscard]]
constexpr uintptr_t
address() const noexcept {
return addr_; }
80 [[nodiscard]]
constexpr span<char>
scratch() const noexcept RELOCO_LIFETIMEBOUND {
return scratch_; }
86 [[nodiscard]]
constexpr size_t max_limit() const noexcept {
return max_limit_; }
92 address_space_ref space_{};
94 span<char> scratch_{};
96 size_t max_limit_{4096};
121 if (view.address() == 0) {
126 if (!view.space() || view.scratch().empty()) {
131 uintptr_t cur = view.address();
134 while (total < view.max_limit()) {
135 auto chunk = view.space().read_string_chunk(cur, view.scratch());
140 out.write(
"<fault>");
145 const size_t chunk_len = chunk->length;
147 const size_t limit_left = view.max_limit() - total;
148 const size_t to_write = (chunk_len > limit_left) ? limit_left : chunk_len;
149 const auto scratch = view.scratch();
150 out.write(microfmt::string_view(scratch.data(), to_write));
155 if (chunk->null_terminated || total >= view.max_limit()) {
160 if (total >= view.max_limit()) {
Type-erased remote address-space access and remote string/object views.
Type-erased, two-word handle to a remote address space.
Definition address_space.hpp:204
Streaming view of a foreign or non-contiguous string.
Definition foreign_string_view.hpp:29
constexpr uintptr_t address() const noexcept
Returns the foreign string address.
Definition foreign_string_view.hpp:68
constexpr size_t max_limit() const noexcept
Returns the maximum render length.
Definition foreign_string_view.hpp:86
constexpr span< char > scratch() const noexcept RELOCO_LIFETIMEBOUND
Returns the scratch chunk buffer.
Definition foreign_string_view.hpp:80
constexpr foreign_string_view(uintptr_t addr, address_space_ref space, char(&scratch RELOCO_LIFETIMEBOUND RELOCO_LIFETIME_CAPTURE_BY_THIS)[N], size_t max_limit=4096) noexcept
Constructs a view over a foreign string using a fixed C array as scratch.
Definition foreign_string_view.hpp:59
constexpr address_space_ref space() const noexcept
Returns the address space handle.
Definition foreign_string_view.hpp:74
constexpr foreign_string_view() noexcept=default
Constructs an empty (null) foreign string view.
Definition microfmt.hpp:881
#define MICROFMT_API_CLASS
Definition compat.hpp:181
reloco::sink sink
Type-erased, zero-allocation output sink.
Definition microfmt.hpp:46
RELOCO_CONSTEXPR20 void format_to(const sink &out, microfmt::string_view fmt, const Args &...args) noexcept
Definition microfmt.hpp:1766