21 #ifndef USTRING_UTILS_H
22 #define USTRING_UTILS_H
26 namespace OpenSkyNet {
29 inline void Tokenize(
const std::string& s_, std::vector<std::string>& tokens_,
const std::string& delimiters_=
" ") {
31 std::string::size_type lastPos = s_.find_first_not_of(delimiters_, 0);
33 std::string::size_type pos = s_.find_first_of(delimiters_, lastPos);
35 while (std::string::npos != pos || std::string::npos != lastPos) {
37 tokens_.push_back(s_.substr(lastPos, pos - lastPos));
39 lastPos = s_.find_first_not_of(delimiters_, pos);
41 pos = s_.find_first_of(delimiters_, lastPos);
45 inline void EraseAll(std::string& s_,
const std::string& charsToErase_=
" ") {
46 std::string::size_type lastErasePos = s_.find_first_of(charsToErase_, 0);
47 while (std::string::npos != lastErasePos) {
48 s_.erase(s_.begin() + lastErasePos);
49 lastErasePos = s_.find_first_of(charsToErase_, lastErasePos);
55 #endif //USTRING_UTILS_H
void Tokenize(const std::string &s_, std::vector< std::string > &tokens_, const std::string &delimiters_=" ")
Definition: UStringUtils.h:29
void EraseAll(std::string &s_, const std::string &charsToErase_=" ")
Definition: UStringUtils.h:45