Strings - Character mapping, conversion to upper/lowercase

This commit is contained in:
Emmanuel BENOîT 2018-05-08 13:58:39 +02:00
parent fbff6e8352
commit d823721fb2
3 changed files with 78 additions and 0 deletions

View file

@ -1447,6 +1447,33 @@ T_String T_String::trim( ) const noexcept
/*----------------------------------------------------------------------------*/
T_String T_String::mapped( T_Character::F_Map f ) const noexcept
{
T_StringIterator it{ *this };
T_StringBuilder sb;
while ( !it.atEnd( ) ) {
sb << f( it );
it.next( );
}
return std::move( sb );
}
T_String T_String::toUpper( ) const noexcept
{
return mapped( [](auto c){
return c.toUpper( );
} );
}
T_String T_String::toLower( ) const noexcept
{
return mapped( [](auto c){
return c.toLower( );
} );
}
/*----------------------------------------------------------------------------*/
int32_t T_String::compare( T_String const& other ) const
{
if ( this == &other || data_ == other.data_ ) {