-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
45 lines (43 loc) · 904 Bytes
/
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
#include <iostream>
#include <exception>
#include "csvparser.hpp"
int main(int argc, char *argv[])
{
try
{
if(argc != 2)
{
throw std::invalid_argument("Arguments quantity is invalid");
}
else
{
std::string filename(argv[1]);
std::string filetype = filename.substr(filename.find("."));
if(filetype == ".csv")
{
std::ifstream f;
f.open(filename, std::fstream::in);
if(f.is_open())
{
CSVParser parser(f);
parser.printInput();
parser.completeTable();
parser.printResault();
f.close();
}
else
{
throw std::invalid_argument("File does not exist");
}
}
else
{
throw std::invalid_argument("Invalid filetype");
}
}
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
}
}