-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.cpp
More file actions
107 lines (96 loc) · 2.32 KB
/
Copy pathutils.cpp
File metadata and controls
107 lines (96 loc) · 2.32 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#include "utils.hpp"
#include <iostream>
//split a string with a char used for delimiter
vector<string> split (const string &s, char delim) {
vector<string> result;
stringstream ss (s);
string item;
while (getline (ss, item, delim)) {
result.push_back (item);
}
return result;
}
//transform a string in uppercase
void upper(string& s){
for(auto &c : s){
c = toupper(c);
}
}
//print all arguments entered by the user
void printAllArguments(int argc, char* argv[]){
cout << "--------PRINT ALL ARGUMENTS--------" << endl;
cout << "number of arguments = " << argc - 2 << endl;
for(int i=2;i<argc;i++){
cout << argv[i] << endl;
}
cout << "-----PRINT ALL ARGUMENTS ENDED-----" << endl;
}
//Test if there is enough arguments for each commands
bool enoughArguments(int argc, char* argv[], int choice){
bool res = false;
switch(choice){
case 'h':
if(argc>1){
res = true;
}
break;
case 'r':
if(argc>3){
res = true;
}
break;
case 'g':
if(argc>=4){
res = true;
}
break;
case 'c':
if(argc>=5){
int nbAlgo2Test = stoi(argv[4]);
if(argc>4+nbAlgo2Test){
res = true;
}
}
break;
case 'a':
if(argc>1){
res = true;
}
}
return res;
}
//Test if there is not too much arguments for each commands
bool notTooMuchArguments(int argc, char* argv[], int choice){
bool res = true;
switch(choice){
case 'h':
if(argc>4){
res = false;
}
break;
case 'r':
if(argc>6){
res = false;
}
break;
case 'g':
if(argc>6){
res = false;
}
break;
case 'c':
if(argc>=5){
int nbAlgo2Test = stoi(argv[4]);
if(argc>6+nbAlgo2Test){
res = false;
}
}
break;
case 'a':
if(argc>2){
res = false;
}
break;
}
return res;
}