Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
62 lines (54 loc) · 1.37 KB

File metadata and controls

62 lines (54 loc) · 1.37 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>
#include <string>
#include <vector>
namespace utils {
std::vector<std::string> SplitString(const std::string_view& data) {
std::vector<std::string> result;
std::string word;
for (size_t i = 0; i < data.size(); ++i) {
if (data[i] != ' ') {
word.push_back(data[i]);
} else if (!word.empty()) {
result.push_back(std::move(word));
word.clear();
}
}
if (!word.empty()) {
result.push_back(word);
}
return result;
}
std::string ContatinateStrings(const std::vector<std::string>& strings,
const std::string& separator) {
std::string result;
for (const auto& string : strings) {
result += separator + string;
}
return result;
}
std::vector<std::string> SplitCommandString(const std::string_view& data) {
std::vector<std::string> result;
std::string word;
int bracket_depth = 0;
for (size_t i = 0; i < data.size(); ++i) {
if (data[i] == '(') {
++bracket_depth;
if (bracket_depth == 1) continue;
}
if (data[i] == ')') {
--bracket_depth;
if (bracket_depth == 0) continue;
}
if (data[i] != ' ' || bracket_depth) {
word.push_back(data[i]);
} else if (!word.empty()) {
result.push_back(std::move(word));
word.clear();
}
}
if (!word.empty()) {
result.push_back(word);
}
return result;
}
} // namespace utils
Morty Proxy This is a proxified and sanitized view of the page, visit original site.