-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
52 lines (48 loc) · 981 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
46
47
48
49
50
51
52
#include "include/Frame.hpp"
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
std::vector<std::string> split_colon(std::string str)
{
std::vector<std::string> v;
std::string::size_type pos;
while ((pos = str.find(":")) != std::string::npos)
{
v.push_back(str.substr(0, pos));
str.erase(0, str.find(":") + 1);
}
return v;
}
int main(int argc, char *argv[])
{
Base base;
std::vector<std::string> v;
if (argc != 3 && argc != 4)
return (-1);
if (argc == 4)
{
v = split_colon(argv[1]);
if (v.size() != 3)
return (-1);
base._host = v[0];
base._serverPort = std::strtod(v[1].c_str(), 0);
base._passwordNetwork = v[2];
base._port = std::strtod(argv[2], 0);
base._password = argv[3];
}
else
{
base._port = std::strtod(argv[1], 0);
base._password = argv[2];
}
try
{
Frame *mainframe = Frame::instance();
mainframe->start(base);
}
catch(std::exception const& err)
{
std::cout << err.what() << "\n";
}
}