nfx-stringbuilderpool 1.0.0
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/StringBuilderPool.h>

Public Member Functions

 StringBuilderLease ()=delete
 Default constructor.
 
 StringBuilderLease (const StringBuilderLease &)=delete
 Copy constructor.
 
 StringBuilderLease (StringBuilderLease &&other) noexcept
 Move constructor.
 
 ~StringBuilderLease ()
 Destructor.
 
StringBuilderLeaseoperator= (const StringBuilderLease &)=delete
 Copy assignment operator.
 
StringBuilderLeaseoperator= (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 695 of file StringBuilderPool.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 ( )
inline

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 ( )
inline

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
inline

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

Friends And Related Symbol Documentation

◆ StringBuilderPool

friend class StringBuilderPool
friend

Definition at line 697 of file StringBuilderPool.h.


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