High-performance string builder with fluent interface and efficient memory management.
More...
|
|
| StringBuilder ()=delete |
| | Default constructor.
|
|
| StringBuilder (const StringBuilder &)=default |
| | Copy constructor.
|
|
| StringBuilder (StringBuilder &&) noexcept=delete |
| | Move constructor.
|
|
| ~StringBuilder ()=default |
| | Destructor.
|
|
StringBuilder & | operator= (const StringBuilder &)=delete |
| | Copy assignment operator.
|
|
StringBuilder & | operator= (StringBuilder &&) noexcept=delete |
| | Move assignment operator.
|
| char & | operator[] (size_t index) |
| | Provides read-write access to character at specified index.
|
| const char & | operator[] (size_t index) const |
| | Provides read-only access to character at specified index.
|
| void | append (std::string_view str) |
| | Appends string_view contents to the buffer efficiently.
|
| void | append (const std::string &str) |
| | Appends std::string contents to the buffer.
|
| void | append (const char *str) |
| | Appends null-terminated C-string to the buffer.
|
| void | append (char c) |
| | Appends single character to the buffer.
|
| StringBuilder & | operator<< (std::string_view str) |
| | Stream operator for string_view.
|
| StringBuilder & | operator<< (const std::string &str) |
| | Stream operator for std::string.
|
| StringBuilder & | operator<< (const char *str) |
| | Stream operator for C-string.
|
| StringBuilder & | operator<< (char c) |
| | Stream operator for single character.
|
| StringBuilder & | operator<< (std::int32_t value) |
| | Stream operator for 32-bit signed integer.
|
| StringBuilder & | operator<< (std::uint32_t value) |
| | Stream operator for 32-bit unsigned integer.
|
| StringBuilder & | operator<< (std::int64_t value) |
| | Stream operator for 64-bit signed integer.
|
| StringBuilder & | operator<< (std::uint64_t value) |
| | Stream operator for 64-bit unsigned integer.
|
| StringBuilder & | operator<< (float value) |
| | Stream operator for single-precision floating-point.
|
| StringBuilder & | operator<< (double value) |
| | Stream operator for double-precision floating-point.
|
| template<typename... Args> |
| StringBuilder & | format (std::format_string< Args... > fmt, Args &&... args) |
| | Format and append text using std::format.
|
| size_t | length () const noexcept |
| | Returns current buffer size in characters.
|
| void | resize (size_t newSize) |
| | Resizes buffer to specified character count.
|
| Iterator | begin () |
| | Returns mutable iterator to beginning of character sequence.
|
| ConstIterator | begin () const |
| | Returns const iterator to beginning of character sequence.
|
| Iterator | end () |
| | Returns mutable iterator to end of character sequence.
|
| ConstIterator | end () const |
| | Returns const iterator to end of character sequence.
|
High-performance string builder with fluent interface and efficient memory management.
Provides a convenient wrapper around DynamicStringBuffer with stream-like operators for intuitive string construction. Features efficient append operations, iterator support, and automatic memory management through the underlying buffer.
- Note
- This class is a lightweight wrapper that references an underlying DynamicStringBuffer. It does not own the buffer memory - use StringBuilderPool::lease() for proper RAII management.
- Warning
- Not thread-safe - external synchronization required for concurrent access. Multiple StringBuilder instances should not reference the same buffer concurrently.
- See also
- StringBuilderPool for the recommended way to obtain StringBuilder instances
-
StringBuilderLease for RAII management of pooled buffers
-
DynamicStringBuffer for the underlying buffer implementation
Definition at line 429 of file StringBuilder.h.
template<typename... Args>
| StringBuilder & nfx::string::StringBuilder::format |
( |
std::format_string< Args... > | fmt, |
|
|
Args &&... | args ) |
|
inline |
Format and append text using std::format.
- Template Parameters
-
| Args | Types of the formatting arguments |
- Parameters
-
| fmt | Format string with format specifiers |
| args | Arguments to be formatted |
- Returns
- Reference to this StringBuilder for chaining
Provides type-safe formatting directly into the builder without intermediate allocations. Uses std::format_to with back_inserter for optimal performance. Example: builder.format("User {} (ID: {}) logged in at {}", name, userId, timestamp);