📄 _str.h
字号:
#ifndef ___str_h__
#define ___str_h__
namespace extension
{
// Function name : trim
// Description : Trm function
// Return type : basic_string< E >
// Argument : const E* s
template< class E >
basic_string< E > trim( const E* s )
{
if( s == NULL )
return basic_string< E >();
const E* i = s;
while( ( *i != '\0' ) && ( *i == ' ' ) )
i++;
if( *i == '\0' )
return basic_string< E >();
const E* j = i;
while( *( j + 1 ) )
j++;
while( ( j != i ) && ( *j == ' ' ) )
j--;
return basic_string< E >( i, j - i + 1 );
}
// Function name : remove_non_lws
// Description : Removes non linear white spaces
// Return type : basic_string< E >
// Argument : const E* s
template< class E >
basic_string< E > remove_non_lws( const E* s )
{
basic_string< E > strResult = s;
basic_string< E >::size_type i = basic_string< E >::npos;
// Remove \r
while( ( i = strResult.find( '\r' ) ) != basic_string< E >::npos )
strResult.erase( i, 1 );
// Remove \n
while( ( i = strResult.find( '\n' ) ) != basic_string< E >::npos )
strResult.erase( i, 1 );
// Remove \r
while( ( i = strResult.find( '\r' ) ) != basic_string< E >::npos )
strResult.erase( i, 1 );
return strResult;
}
} // Namespace extension
#endif // ___str_h__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -