23namespace swoc {
inline namespace SWOC_VERSION_NS {
69 virtual const char *
data()
const = 0;
242 template <
typename Binding,
typename Extractor>
255 template <
typename Binding,
typename Extractor>
BufferWriter &
print_nfv(Binding
const &names, Extractor &&ex);
296 virtual std::ostream &
operator>>(std::ostream &stream)
const = 0;
347 const char *
data()
const override;
350 bool error()
const override;
359 size_t extent()
const override;
362 bool commit(
size_t n)
override;
365 self_type &
discard(
size_t n)
override;
368 self_type &
restrict(
size_t n)
override;
371 self_type &
restore(
size_t n)
override;
390 operator std::string_view()
const;
396 std::ostream &
operator>>(std::ostream &stream)
const override;
399 template <
typename... Rest> self_type &
print(
TextView fmt, Rest &&...rest);
401 template <
typename... Args> self_type &
print_v(
TextView fmt, std::tuple<Args...>
const &args);
403 template <
typename... Args> self_type &
print(
bwf::Format const &fmt, Args &&...args);
405 template <
typename... Args> self_type &
print_v(
bwf::Format const &fmt, std::tuple<Args...>
const &args);
458inline BufferWriter::~BufferWriter() {}
462 const char *d =
static_cast<const char *
>(
data);
473 return this->write(sv.data(), sv.size());
499 if (
_capacity != 0 && buffer ==
nullptr) {
500 throw(std::invalid_argument{
"FixedBufferWriter created with null buffer and non-zero size."});
514inline FixedBufferWriter::self_type &
515FixedBufferWriter::detach() {
516 const_cast<char *&
>(
_buffer) =
nullptr;
527inline FixedBufferWriter::self_type &
605 throw(std::invalid_argument{
"FixedBufferWriter restrict value more than capacity"});
637 std::memmove(dst_span.data(), src_span.data(), std::min(dst_span.size(), src_span.size()));
646inline FixedBufferWriter::operator std::string_view()
const {
662operator<<(ostream &s, swoc::BufferWriter
const &w) {
virtual bool commit(size_t n)=0
virtual BufferWriter & copy(size_t dst, size_t src, size_t n)=0
virtual bool error() const =0
BufferWriter & print(const TextView &fmt, Args &&...args)
virtual std::ostream & operator>>(std::ostream &stream) const =0
BufferWriter & print_nfv(Binding &&names, Extractor &&ex, bwf::ArgPack const &args)
BufferWriter & format(bwf::Spec const &spec, T &&t)
virtual BufferWriter & discard(size_t n)=0
BufferWriter & print_n(Binding const &names, TextView const &fmt)
virtual BufferWriter & restore(size_t n)=0
virtual BufferWriter & restrict(size_t n)=0
BufferWriter & print_v(const TextView &fmt, const std::tuple< Args... > &args)
virtual size_t capacity() const =0
virtual size_t extent() const =0
virtual BufferWriter & write(char c)=0
virtual const char * data() const =0
MemSpan< char > aux_span()
virtual char * aux_data()
FixedBufferWriter(char *buffer, size_t capacity)
operator swoc::TextView() const
Provide a string_view of all successfully written characters as a user conversion.
size_t extent() const override
Get the total output sent to the writer.
swoc::TextView view() const
char * aux_data() override
self_type & restrict(size_t n) override
Reduce the capacity by n.
bool error() const override
self_type & restore(size_t n) override
Restore n bytes of the capacity.
size_t _capacity
Size of output buffer.
size_t capacity() const override
Get the total capacity of the output buffer.
FixedBufferWriter & copy(size_t dst, size_t src, size_t n) override
Copy data in the buffer.
self_type & assign(MemSpan< char > const &span)
Reset buffer.
const char * data() const override
Return the output buffer.
FixedBufferWriter & write(char c) override
Write a single character c to the buffer.
std::ostream & operator>>(std::ostream &stream) const override
Output the buffer contents to the stream.
size_t _attempted
Number of characters written, including those discarded due error condition.
bool commit(size_t n) override
Advance the used part of the output buffer.
self_type & discard(size_t n) override
Drop n characters from the end of the buffer.
char *const _buffer
Output buffer.
LocalBufferWriter() noexcept
Construct an empty writer.
char _arr[N]
output buffer.
constexpr size_t size() const
Number of elements in the span.
For template deduction guides.