_str.h
来自「http代理程序」· C头文件 代码 · 共 65 行
H
65 行
#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 + =
减小字号Ctrl + -
显示快捷键?