10#ifndef STRING_INPLACE_HPP
11#define STRING_INPLACE_HPP
24 friend class InPlaceReplacement;
53 [[nodiscard]]
bool AnyBytesWritten() const noexcept {
return this->position != 0; }
63 [[nodiscard]] std::string_view
GetWrittenData() const noexcept {
return {this->dest.data(), this->position}; }
68 void PutBuffer(std::span<const
char> str) override;
89 back_insert_iterator
operator++(
int) {
return *
this; }
Compose data into a string / buffer.
void PutChar(char c)
Append 8-bit char.
std::string_view::size_type size_type
The type of the size of our strings.
Implementation of std::back_insert_iterator for non-growing destination buffer.
back_insert_iterator(InPlaceBuilder &parent)
Create the iterator.
std::output_iterator_tag iterator_category
C++ specification trait 'iterator_category' of std::back_insert_iterator.
void difference_type
C++ specification trait 'difference_type' of std::back_insert_iterator.
void reference
C++ specification trait 'reference' of std::back_insert_iterator.
void value_type
C++ specification trait 'value_type' of std::back_insert_iterator.
InPlaceBuilder * parent
The builder we belong to.
void pointer
C++ specification trait 'pointer' of std::back_insert_iterator.
Builder implementation for InPlaceReplacement.
bool AnyBytesWritten() const noexcept
Check whether any bytes have been written.
void AssignBuffer(const InPlaceBuilder &src)
Copy assignment of the buffer and its position.
bool AnyBytesUnused() const noexcept
Check whether any unused bytes are left between the Builder and Consumer position.
std::string_view GetWrittenData() const noexcept
Get already written data.
InPlaceBuilder(std::span< char > dest, const StringConsumer &consumer)
Create this builder.
back_insert_iterator back_inserter()
Create a back-insert-iterator.
size_type GetBytesUnused() const noexcept
Get number of unused bytes left between the Builder and Consumer position.
InPlaceBuilder(const InPlaceBuilder &src, const StringConsumer &consumer)
Create this builder based on an existing builder's buffer.
const StringConsumer & consumer
The string consumer to read with.
size_type GetBytesWritten() const noexcept
Get number of already written bytes.
std::span< char > dest
The buffer to process.
size_type position
The location to write to.
void PutBuffer(std::span< const char > str) override
Append buffer.
InPlaceReplacement(std::span< char > buffer)
Create coupled Consumer+Builder pair.
InPlaceBuilder builder
Builder into shared buffer.
StringConsumer consumer
Consumer from shared buffer.
Parse data from a string / buffer.
constexpr enum_type & operator++(enum_type &e)
Prefix increment.
Compose strings from textual and binary data.