utils.h
Go to the documentation of this file.
1 /*
2 # Software License Agreement (MIT License)
3 #
4 # Copyright (c) 2019, UFACTORY, Inc.
5 # All rights reserved.
6 #
7 # Author: Vinman <vinman.wen@ufactory.cc> <vinman.cub@gmail.com>
8 */
9 #ifndef WRAPPER_COMMON_UTILS_H_
10 #define WRAPPER_COMMON_UTILS_H_
11 
12 #include <iostream>
13 #include <vector>
14 
15 inline std::vector<std::string> split(const std::string &str, const std::string &pattern)
16 {
17 
18  std::vector<std::string> resVec;
19 
20  if ("" == str)
21  {
22  return resVec;
23  }
24 
25  std::string strs = str + pattern;
26 
27  size_t pos = strs.find(pattern);
28  size_t size = strs.size();
29 
30  while (pos != std::string::npos)
31  {
32  std::string x = strs.substr(0, pos);
33  resVec.push_back(x);
34  strs = strs.substr(pos + 1, size);
35  pos = strs.find(pattern);
36  }
37 
38  return resVec;
39 }
40 
41 #endif
std::vector< std::string > split(const std::string &str, const std::string &pattern)
Definition: utils.h:15


xarm_api
Author(s):
autogenerated on Sat May 8 2021 02:51:23