~singpolyma/biboumi

ref: f0f3d3d4e2fb7c02a5b2ad517632ec5071fefb45 biboumi/src/utils/split.cpp -rw-r--r-- 437 bytes
f0f3d3d4 — louiz’ Remove the now useless “find … touch” hack in gitlab-ci.yml 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <utils/split.hpp>
#include <sstream>

namespace utils
{
  std::vector<std::string> split(const std::string& s, const char delim, const bool allow_empty)
  {
    std::vector<std::string> ret;
    std::stringstream ss(s);
    std::string item;
    while (std::getline(ss, item, delim))
      {
        if (item.empty() && !allow_empty)
          continue ;
        ret.emplace_back(std::move(item));
      }
    return ret;
  }
}