Chameleon Applications

Chameleon Applications Commit Details

Date:2010-01-22 20:27:29 (14 years 2 months ago)
Author:Rekursor
Commit:41
Parents: 40
Message:documented more str_util.h remove unnecessary string duplication
Changes:
M/trunk/ChameleonPrefPane/Sources/string_util.h

File differences

trunk/ChameleonPrefPane/Sources/string_util.h
77
88
99
10
10
1111
12
12
1313
1414
15
15
1616
1717
1818
19
19
2020
21
21
2222
2323
24
24
2525
2626
2727
28
28
2929
30
30
3131
32
33
32
3433
*/
/**
* trim the space chars on the right of a sring
* trim the space (or any substring) chars on the right of a sring
*/
inline std::string trim_right(const std::string &source , const std::string& t = " ")
inline std::string trim_right(const std::string &source , const std::string& substr = " ")
{
std::string str = source;
return str.erase( str.find_last_not_of(t) + 1);
return str.erase( str.find_last_not_of(substr) + 1);
}
/**
* trim the space chars on the left of a sring
* trim the space chars (or any substring) on the left of a sring
*/
inline std::string trim_left( const std::string& source, const std::string& t = " ")
inline std::string trim_left( const std::string& source, const std::string& substr = " ")
{
std::string str = source;
return str.erase(0 , source.find_first_not_of(t) );
return str.erase(0 , source.find_first_not_of(substr) );
}
/**
* trim the space chars on the left and the right of a string
* trim the space chars (or any substring) on the left and the right of a string
*/
inline std::string trim(const std::string& source, const std::string& t = " ")
inline std::string trim(const std::string& source, const std::string& substr = " ")
{
std::string str = source;
return trim_left( trim_right( str , t) , t );
return trim_left( trim_right( source , substr) , substr );
}

Archive Download the corresponding diff file

Revision: 41