Changeset 13221
- Timestamp:
- 03/26/12 08:46:02 (13 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/tools.cc
r13168 r13221 76 76 // -------------------------------------------------------------------------- 77 77 // 78 //! This is a static helper to remove leading and trailing whitespaces and 79 //! if available leading and trailing quotes, can be either ' or " 80 //! 81 //! @param buf 82 //! a pointer to the char array to be trimmed 83 //! 84 //! @returns 85 //! a std::string with the content trimmed 86 // 87 string Tools::TrimQuotes(const string &str) 88 { 89 string rc = Trim(str); 90 if (rc.length()<2) 91 return rc; 92 93 const char b = rc[0]; 94 const char e = rc[rc.length()-1]; 95 96 if ((b=='\"' && e=='\"') || (b=='\'' && e=='\'')) 97 return rc.substr(1, rc.length()-2); 98 99 return rc; 100 } 101 102 // -------------------------------------------------------------------------- 103 // 78 104 //! This is a static helper to remove leading and trailing whitespaces. 79 105 //! -
trunk/FACT++/src/tools.h
r13168 r13221 9 9 std::string Form(const char *fmt, ...); 10 10 std::string Trim(const std::string &str); 11 std::string TrimQuotes(const std::string &str); 11 12 std::string Wrap(std::string &str, size_t width=78); 12 13 }
Note:
See TracChangeset
for help on using the changeset viewer.