ALib C++ Library
Library Version: 2402 R1
Documentation generated by doxygen
Loading...
Searching...
No Matches
TStringLengthResetter< TChar > Class Template Reference

Description:

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

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.

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

#include <astring.hpp>

Public Method Index:

 TStringLengthResetter (TAString< TChar > &pAString)
 
 ~TStringLengthResetter ()
 
integer OriginalLength ()
 
void ResetNow ()
 

Field Details:

◆ aString

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

The AString to reset.

Definition at line 2081 of file astring.hpp.

◆ originalLength

template<typename TChar >
integer originalLength
protected

The The original length of the string.

Definition at line 2082 of file astring.hpp.

Constructor(s) / Destructor Details::

◆ TStringLengthResetter()

template<typename TChar >
TStringLengthResetter ( TAString< TChar > & 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 2103 of file astring.hpp.

◆ ~TStringLengthResetter()

template<typename TChar >
~TStringLengthResetter ( )
inline

Destructor. Restores the string's original length.

Definition at line 2109 of file astring.hpp.

Method Details:

◆ operator new() [1/2]

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

Private new to disallow heap allocation.

Returns
Never called.

◆ operator new() [2/2]

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

Private new to disallow heap allocation.

Returns
Never called.

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

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

Private new to disallow heap allocation.

Returns
Never called.

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

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

Private new to disallow heap allocation.

Returns
Never called.

◆ operator=()

template<typename TChar >
void operator= ( const TStringLengthResetter< TChar > & )
private

Private assignment operator.

◆ OriginalLength()

template<typename TChar >
integer OriginalLength ( )
inline

Returns the original length.

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

Definition at line 2121 of file astring.hpp.

◆ ResetNow()

template<typename TChar >
void ResetNow ( )
inline

Resets the strings to the original length prior to 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 2116 of file astring.hpp.


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