-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
61 lines (48 loc) · 2.08 KB
/
main.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
50
51
52
53
54
55
56
57
58
59
60
61
#include <iostream>
#include <string>
#include "DoubleGenerator.h"
#include "DoubleSorter.h"
int main(int argc, char** argv)
{
if (argc == 4 && std::string(argv[1]) == std::string("-g")) { // Generate
MyLib::DoubleGenerator::generateToFile(argv[2], std::stoi(argv[3]));
return 0;
} else if (argc == 3) { // Sort
MyLib::DoubleSorter doubleSorter(argv[1], argv[2]);
doubleSorter.sort();
return 0;
} else if (argc == 4 && (std::string(argv[3]) == std::string("-a") || std::string(argv[3]) == std::string("-d"))) { // Sort
MyLib::DoubleSorter::Order order;
if (std::string(argv[3]) == std::string("-a")) {
order = MyLib::DoubleSorter::Order::ascending;
} else {
order = MyLib::DoubleSorter::Order::descending;
}
MyLib::DoubleSorter doubleSorter(argv[1], argv[2], order);
doubleSorter.sort();
return 0;
} else if (argc == 5 && (std::string(argv[3]) == std::string("-a") || std::string(argv[3]) == std::string("-d"))) { // Sort
MyLib::DoubleSorter::Order order;
if (std::string(argv[3]) == std::string("-a")) {
order = MyLib::DoubleSorter::Order::ascending;
} else {
order = MyLib::DoubleSorter::Order::descending;
}
MyLib::DoubleSorter doubleSorter(argv[1], argv[2], order, std::stoi(argv[4]));
doubleSorter.sort();
return 0;
} else {
std::cout << "Wrong parameters!" << std::endl;
std::cout << "Parameters should be:" << std::endl;
std::cout << "For generate:" << std::endl;
std::cout << "1) <action> = \'-g\'" << std::endl;
std::cout << "2) <output file name>" << std::endl;
std::cout << "3) <quantity>" << std::endl;
std::cout << "For sort:" << std::endl;
std::cout << "1) <input file name>" << std::endl;
std::cout << "2) <output file name>" << std::endl;
std::cout << "3) [<order>] = \'-a\' | \'-d\'" << std::endl;
std::cout << "4) [<max ram usage in bytes>] >= 10485760" << std::endl;
return 1;
}
}