nfx-stringbuilder 0.1.1
High-performance C++20 library for zero-allocation string building with thread-safe pooling
Loading...
Searching...
No Matches
nfx::string::StringBuilderLease Class Referencefinal

RAII lease wrapper for pooled StringBuilder buffers with automatic resource management. More...

#include <nfx/string/StringBuilder.h>

Public Member Functions

 StringBuilderLease ()=delete
 Default constructor.
 StringBuilderLease (const StringBuilderLease &)=delete
 Copy constructor.
 StringBuilderLease (StringBuilderLease &&other) noexcept
 Move constructor.
 ~StringBuilderLease ()
 Destructor.
StringBuilderLease & operator= (const StringBuilderLease &)=delete
 Copy assignment operator.
StringBuilderLease & operator= (StringBuilderLease &&other) noexcept
 Move assignment operator.
StringBuilder create ()
 Creates StringBuilder wrapper for buffer manipulation.
DynamicStringBufferbuffer ()
 Provides direct access to underlying memory buffer.
std::string toString () const
 Converts buffer contents to std::string.

Friends

class StringBuilderPool

Detailed Description

RAII lease wrapper for pooled StringBuilder buffers with automatic resource management.

Provides exclusive access to a pooled DynamicStringBuffer through RAII semantics. Automatically returns the buffer to the pool when the lease is destroyed, ensuring optimal memory reuse and preventing resource leaks. Features move-only semantics for safe transfer of ownership and convenient access methods.

Note
This class implements move-only semantics - copying is disabled to prevent multiple ownership of the same buffer. Use std::move() for ownership transfer.
Warning
Not thread-safe - external synchronization required for concurrent access. Do not share lease instances between threads without proper synchronization.
See also
StringBuilderPool::lease() for obtaining lease instances
StringBuilder for the high-level string building interface
DynamicStringBuffer for the underlying buffer implementation

Definition at line 705 of file StringBuilder.h.

Constructor & Destructor Documentation

◆ StringBuilderLease()

nfx::string::StringBuilderLease::StringBuilderLease ( StringBuilderLease && other)
inlinenoexcept

Move constructor.

Parameters
otherThe StringBuilderLease to move from

Member Function Documentation

◆ buffer()

DynamicStringBuffer & nfx::string::StringBuilderLease::buffer ( )
inlinenodiscard

Provides direct access to underlying memory buffer.

Returns
Reference to the underlying DynamicStringBuffer
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ create()

StringBuilder nfx::string::StringBuilderLease::create ( )
inlinenodiscard

Creates StringBuilder wrapper for buffer manipulation.

Returns
StringBuilder instance wrapping the leased buffer
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ operator=()

StringBuilderLease & nfx::string::StringBuilderLease::operator= ( StringBuilderLease && other)
inlinenoexcept

Move assignment operator.

Parameters
otherThe StringBuilderLease to move from
Returns
Reference to this StringBuilderLease after assignment

◆ toString()

std::string nfx::string::StringBuilderLease::toString ( ) const
inlinenodiscard

Converts buffer contents to std::string.

Returns
String copy of the buffer contents
Note
This function is marked [[nodiscard]] - the return value should not be ignored

◆ StringBuilderPool

friend class StringBuilderPool
friend

Definition at line 707 of file StringBuilder.h.


The documentation for this class was generated from the following file: