String builder - truncate() method
This commit is contained in:
parent
5db261909a
commit
86a3fe34b4
3 changed files with 36 additions and 0 deletions
include/ebcl
|
@ -391,6 +391,7 @@ class T_StringBuilder
|
|||
T_StringBuilder& ensureCapacity( uint32_t minCap );
|
||||
T_StringBuilder& clear( );
|
||||
T_StringBuilder& free( );
|
||||
T_StringBuilder& truncate( uint32_t maxLength ) noexcept;
|
||||
|
||||
// ---------------------------------------------------------------------
|
||||
|
||||
|
|
|
@ -458,6 +458,16 @@ inline T_StringBuilder& T_StringBuilder::clear( )
|
|||
return *this;
|
||||
}
|
||||
|
||||
inline T_StringBuilder& T_StringBuilder::truncate(
|
||||
const uint32_t maxLength ) noexcept
|
||||
{
|
||||
if ( maxLength < length_ ) {
|
||||
size_ = UTF8GetMemoryOffset( data_ , maxLength );
|
||||
length_ = maxLength;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
inline bool T_StringBuilder::operator== ( T_StringBuilder const& other ) const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue