summaryrefslogtreecommitdiff
path: root/src/utils/split.hpp
blob: 0067131f23ac2baa15fbd6a75d18904ae5408283 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef SPLIT_INCLUDED
# define SPLIT_INCLUDED

#include <string>
#include <sstream>
#include <vector>

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

#endif // SPLIT_INCLUDED