Chameleon Applications

Chameleon Applications Svn Source Tree

Root/trunk/ChameleonPrefPane/Sources/string_util.h

1/*
2 * string_util.h
3 * ChameleonPrefPane
4 *
5 * Created by Rekursor on 1/22/10.
6 *
7 */
8
9/**
10 * trim the space chars on the right of a sring
11 */
12inline std::string trim_right(const std::string &source , const std::string& t = " ")
13{
14std::string str = source;
15return str.erase( str.find_last_not_of(t) + 1);
16}
17
18/**
19 * trim the space chars on the left of a sring
20 */
21inline std::string trim_left( const std::string& source, const std::string& t = " ")
22{
23std::string str = source;
24return str.erase(0 , source.find_first_not_of(t) );
25}
26
27/**
28 * trim the space chars on the left and the right of a string
29 */
30inline std::string trim(const std::string& source, const std::string& t = " ")
31{
32std::string str = source;
33return trim_left( trim_right( str , t) , t );
34}
35

Archive Download this file

Revision: 40