This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void trim( std::string& str, const std::string& whitespaces=" \t\f\v\n\r" ) | |
| { | |
| size_t found = str.find_first_not_of( whitespaces ); | |
| if ( found!=std::string::npos ) | |
| str.erase( 0, found ); | |
| else | |
| str.clear(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace | |
| { | |
| struct add_delimiter | |
| { | |
| add_delimiter( const std::string& d ) | |
| { delimiter = d; } | |
| std::string operator()( const std::string& lhs, const std::string& rhs ) | |
| { return lhs + (lhs.empty() ? "" : delimiter) + rhs; } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void chop( std::string& str, const std::string& whitespaces=" \t\f\v\n\r" ) | |
| { | |
| size_t found = str.find_last_not_of( whitespaces ); | |
| if ( found!=std::string::npos ) | |
| str.erase( found+1 ); | |
| else | |
| str.clear(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void split( const std::string& str, char delim, std::vector<std::string>& tokens ) | |
| { | |
| std::stringstream iss(str); | |
| std::string item; | |
| while ( std::getline(iss, item, delim) ) | |
| { | |
| if ( !item.empty() ) | |
| tokens.push_back(item); | |
| } | |
| } |
NewerOlder