ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
TStringLengthResetter< TChar, TAllocator > Class Template Reference

Description:

template<typename TChar, typename TAllocator>
class alib::strings::TStringLengthResetter< TChar, TAllocator >

This is a simple utility class that can be used in situations where a AString is intermediately extended and later shortened back to its original length. With the use of this class, C++ stack-unwinding is used to ensure that the length is reset in all execution paths including exception handling, etc.

See also
Macro ALIB_STRING_RESETTER which automatically creates a unique identifier for the otherwise unused instances of this type.
Template Parameters
TCharThe character type of the AString that is to be reset.
TAllocatorThe allocator type of the AString, as prototyped with Allocator.

Definition at line 41 of file strings/fwds.hpp.

Public Method Index:

 TStringLengthResetter (TAString< TChar, TAllocator > &pAString)
 
 ~TStringLengthResetter ()
 Destructor. Restores the string's original length.
 
integer OriginalLength ()
 
void ResetNow ()
 

Protected Field Index:

TAString< TChar, TAllocator > & aString
 The AString to reset.
 
integer originalLength
 The The original length of the string.
 

Private Method Index:

void * operator new (size_t)
 
void * operator new (size_t, void *)
 
void * operator new[] (size_t)
 
void * operator new[] (size_t, void *)
 
void operator= (const TStringLengthResetter &)
 Private assignment operator.
 

Field Details:

◆ aString

template<typename TChar , typename TAllocator >
TAString<TChar,TAllocator>& aString
protected

The AString to reset.

Definition at line 2090 of file tastring.inl.

◆ originalLength

template<typename TChar , typename TAllocator >
integer originalLength
protected

The The original length of the string.

Definition at line 2091 of file tastring.inl.

Constructor(s) / Destructor Details:

◆ TStringLengthResetter()

template<typename TChar , typename TAllocator >
TStringLengthResetter ( TAString< TChar, TAllocator > & pAString)
inline

Constructor taking the string. Stores the current length in field originalLength.

Parameters
pAStringThe String to take the length of and reset on destruction.

Definition at line 2112 of file tastring.inl.

◆ ~TStringLengthResetter()

template<typename TChar , typename TAllocator >
~TStringLengthResetter ( )
inline

Destructor. Restores the string's original length.

Definition at line 2118 of file tastring.inl.

Method Details:

◆ operator new() [1/2]

template<typename TChar , typename TAllocator >
void * operator new ( size_t )
private

Private new to disallow heap allocation.

Returns
Never called.

◆ operator new() [2/2]

template<typename TChar , typename TAllocator >
void * operator new ( size_t ,
void *  )
private

Private new to disallow heap allocation.

Returns
Never called.

◆ operator new[]() [1/2]

template<typename TChar , typename TAllocator >
void * operator new[] ( size_t )
private

Private new to disallow heap allocation.

Returns
Never called.

◆ operator new[]() [2/2]

template<typename TChar , typename TAllocator >
void * operator new[] ( size_t ,
void *  )
private

Private new to disallow heap allocation.

Returns
Never called.

◆ OriginalLength()

template<typename TChar , typename TAllocator >
integer OriginalLength ( )
inline

Returns the original length.

Returns
The length of the AString when this object was constructed.

Definition at line 2130 of file tastring.inl.

◆ ResetNow()

template<typename TChar , typename TAllocator >
void ResetNow ( )
inline

Resets the strings to the original length before destruction of this object.

Note
With using macro ALIB_STRING_RESETTER, this method is not invocable, because the name of the object is not available in this case. But this method is not a true member of the usual use case of this class.

Definition at line 2125 of file tastring.inl.


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