src/utils/string.cpp
/**
   * Explode string by delim, include empty tokens
   */
Explode string by delim, include empty tokens
Explode string by delim include empty tokens
std::vector<std::string> tokenize(const string& str, char delimiters) {
    std::vector<std::string> tokens;
    std::string::size_type lastPos = 0;
    auto pos = str.find_first_of(delimiters, lastPos);
    while (pos != std::string::npos && lastPos != std::string::npos) {
      tokens.emplace_back(str.substr(lastPos, pos - lastPos));
      lastPos = pos + 1;
      pos = str.find_first_of(delimiters, lastPos);
    }
    tokens.emplace_back(str.substr(lastPos, pos - lastPos));
    return tokens;
  }
std :: vector < std :: string > tokenize ( const string & str , char delimiters ) { std :: vector < std :: string > tokens ; std :: string :: size_type lastPos = 0 ; auto pos = str . find_first_of ( delimiters , lastPos ) ; while ( pos != std :: string :: npos && lastPos != std :: string :: npos ) { tokens . emplace_back ( str . substr ( lastPos , pos - lastPos ) ) ; lastPos = pos + 1 ; pos = str . find_first_of ( delimiters , lastPos ) ; } tokens . emplace_back ( str . substr ( lastPos , pos - lastPos ) ) ; return tokens ; }
Explode string by delim, include empty tokens
Explode string by delim include empty tokens