135 [[nodiscard]]
size_t size() const noexcept;
167 static constexpr
size_t kDefaultCapacity{256};
168 static constexpr size_t kMinCapacity{64};
169 static constexpr size_t kMaxExpandSize{8192};
171 class VLINK_EXPORT StringBuf final :
public std::streambuf {
173 explicit StringBuf(
size_t initial_capacity = kDefaultCapacity)
noexcept;
175 void reset() noexcept;
177 void shrink_to_fit() noexcept;
179 void append_to(std::
string& target) const noexcept;
181 [[nodiscard]] std::string_view take_view() noexcept;
183 [[nodiscard]]
size_t size() const noexcept;
185 [[nodiscard]]
size_t capacity() const noexcept;
187 [[nodiscard]] int_type overflow(int_type ch) override;
189 std::streamsize xsputn(const
char* s, std::streamsize n) override;
192 void grow_buffer(
size_t required_size) noexcept;
194 void advance_pptr(
size_t count) noexcept;
std::string_view take_view() noexcept
Returns a std::string_view of the current buffer contents.
size_t size() const noexcept
Returns the current number of bytes stored in the buffer.
size_t capacity() const noexcept
Returns the current allocated capacity of the internal buffer in bytes.
void reset() noexcept
Clears all buffered content and resets the stream error state.
FastStream & write_raw(const char *data, size_t len) noexcept
Writes raw bytes directly into the buffer, bypassing std::ostream formatting.
FastStream() noexcept
Constructs a FastStream with a default initial buffer capacity.
void append_to(std::string &target) const noexcept
Appends the current buffered content to an existing std::string.
void shrink_to_fit() noexcept
Releases any excess capacity allocated by the internal buffer.
Platform-independent macro definitions for the VLink library.
#define VLINK_EXPORT
Definition macros.h:85
#define VLINK_DISALLOW_COPY_AND_ASSIGN(classname)
Deletes the copy constructor and copy-assignment operator of classname.
Definition macros.h:184