-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.cpp
49 lines (39 loc) · 1.24 KB
/
util.cpp
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
#include "util.hpp"
#include "TernarySearchTree.hpp"
std::string util::str::to_upper(std::string input)
{
for (char& c : input)
c = toupper(c);
return input;
}
std::vector<std::string> util::str::split(std::string definition)
{
std::vector<std::string> words;
std::vector<char> stop = { ':', '\t', '\'', ' ',
',', '.', '?', '!',
'@', '#', '(', ')',
'|' , ';', '"', '`', '\'',
'!', '$', '%', '^', '&', '*',
'-', '_', '+', '=', '{', '}',
'\\', '<', '>' };
std::string temp;
for (size_t i = 0; i < definition.size(); i++)
{
bool check = true;
for (int j = 0; j < stop.size() && check; j++)
check = (definition[i] != stop[j]);
if (check)
{
temp.push_back(definition[i]);
}
else
{
if (!temp.empty())
words.push_back(util::str::to_upper(temp));
temp.clear();
}
}
if (!temp.empty())
words.push_back(util::str::to_upper(temp));
return words;
}