72 #include <string_view>
109 void reset() noexcept;
116 void append_to(std::
string& target) const noexcept;
130 std::string_view take_view();
137 [[nodiscard]]
size_t size() const noexcept;
144 [[nodiscard]]
size_t capacity() const noexcept;
152 void shrink_to_fit() noexcept;
168 static constexpr
size_t kDefaultCapacity{256};
169 static constexpr
size_t kMinCapacity{64};
170 static constexpr
size_t kMaxExpandSize{8192};
172 class VLINK_EXPORT StringBuf final :
public std::streambuf {
174 explicit StringBuf(
size_t initial_capacity = kDefaultCapacity);
176 void reset() noexcept;
178 void shrink_to_fit() noexcept;
180 void append_to(std::
string& target) const noexcept;
182 [[nodiscard]] std::string_view take_view();
184 [[nodiscard]]
size_t size() const noexcept;
186 [[nodiscard]]
size_t capacity() const noexcept;
188 [[nodiscard]] int_type overflow(int_type ch) override;
190 std::streamsize xsputn(const
char* s, std::streamsize n) override;
193 void grow_buffer(
size_t required_size);
195 void advance_pptr(
size_t count) noexcept;
Logger-friendly std::ostream with a custom growable string buffer.
Definition: fast_stream.h:88
FastStream() noexcept
Constructs the stream with the default initial backing capacity.
Cross-platform macros for visibility, branch hints, copy prevention, singletons and string helpers.
#define VLINK_EXPORT
Definition: macros.h:81
#define VLINK_DISALLOW_COPY_AND_ASSIGN(classname)
Deletes the copy constructor and copy-assignment operator of classname.
Definition: macros.h:174