Changeset 10338 for trunk/FACT++/src
- Timestamp:
- 04/10/11 10:09:40 (14 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/tools.cc
r10183 r10338 49 49 return str; 50 50 } 51 52 // -------------------------------------------------------------------------- 53 // 54 //! This is a static helper to remove leading and trailing whitespaces. 55 //! 56 //! @param buf 57 //! a pointer to the char array from which the whitespaces should be 58 //! removed 59 //! 60 //! @returns 61 //! a std::string with the whitespaces removed from buf 62 // 63 string Trim(const string &str) 64 { 65 // Trim Both leading and trailing spaces 66 const size_t start = str.find_first_not_of(' '); // Find the first character position after excluding leading blank spaces 67 const size_t end = str.find_last_not_of(' '); // Find the first character position from reverse af 68 69 // if all spaces or empty return an empty string 70 if (string::npos==start || string::npos==end) 71 return string(); 72 73 return str.substr(start, end-start+1); 74 } -
trunk/FACT++/src/tools.h
r10183 r10338 3 3 std::string Format(const char *fmt, va_list &ap); 4 4 std::string Form(const char *fmt, ...); 5 std::string Trim(const std::string &str);
Note:
See TracChangeset
for help on using the changeset viewer.