PABLO  0.1
PArallel Balanced Linear Octree
 All Classes Functions Variables Pages
stringTools.hh
1 // =================================================================================== //
2 // PRE-COMPILATION INSTRUCTIONS //
3 // =================================================================================== //
4 #ifndef STRINGTOOLS_HH
5 #define STRINGTOOLS_HH
6 
7 // includes
8 #include<algorithm>
9 #include<string>
10 #include<functional>
11 #include<cctype>
12 
13 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //
14 // Left Trimming
15 static inline std::string &ltrim(std::string &s) {
16  s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
17  return s;
18 }
19 
20 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //
21 // Right trimming
22 static inline std::string &rtrim(std::string &s) {
23  s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
24  return s;
25 }
26 
27 // xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx //
28 // String trimming (left & right)
29 static inline std::string &trim(std::string &s) {
30  return ltrim(rtrim(s));
31 }
32 
33 #endif