-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.cpp
More file actions
40 lines (37 loc) · 949 Bytes
/
Utils.cpp
File metadata and controls
40 lines (37 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "includes/Utils.hpp"
std::vector<std::string> Utils::split(std::string &str, char delim)
{
std::vector<std::string> result;
std::stringstream ss(str);
std::string token;
while (std::getline(ss, token, delim))
{
if (token.size() == 0)
continue;
result.push_back(token);
}
return result;
}
std::vector<std::string> Utils::concatParams(std::vector<std::string> ¶ms)
{
std::vector<std::string> new_params;
std::string all;
for (size_t i = 0; i < params.size(); i++)
{
if (params[i][0] == ':')
{
while (i < params.size())
{
all += params[i];
if (i != params.size() - 1)
all += " ";
i++;
}
new_params.push_back(all);
break;
}
else
new_params.push_back(params[i]);
}
return new_params;
}