-
Notifications
You must be signed in to change notification settings - Fork 0
/
splitTAD.h
65 lines (52 loc) · 1.26 KB
/
splitTAD.h
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
63
64
65
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
vector<string> split(string stringPrincipal, char delimitador=' ')
{
istringstream stringStream(stringPrincipal);
string stringAuxiliar;
vector<string> retorno;
while (getline(stringStream, stringAuxiliar, delimitador))
{
retorno.push_back(stringAuxiliar);
}
return retorno;
}
vector<string> splitPath(string stringPrincipal)
{
vector<string> caminhoOrigem;
if(stringPrincipal.at(0) == '/') {
caminhoOrigem.push_back("/");
for(const string& elem : split(stringPrincipal, '/'))
{
if (strcmp(elem.c_str(), "") != 0)
caminhoOrigem.push_back(elem);
}
}
else {
caminhoOrigem = split(stringPrincipal, '/');
}
return caminhoOrigem;
}
string lastPosition(vector<string> vector)
{
return vector.at(vector.size()-1);
}
int ocorrenciaString(string conteudo, char caracterBuscado)
{
int qtd=0;
for(int i=0; i<conteudo.size(); i++)
{
if (caracterBuscado == conteudo.at(i))
qtd++;
}
return qtd;
}
string stringToLower(string palavra){
for (auto& x : palavra) {
x = tolower(x);
}
return palavra;
}