-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
56 lines (41 loc) · 1.59 KB
/
main.cpp
File metadata and controls
56 lines (41 loc) · 1.59 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
//
#include "params.hpp"
#include "bin2hpp.hpp"
// std
#include <string>
#include <fstream>
int main(int argc, char *argv[]){
auto cmdline = params::cmdlinetovector(argc, argv);
if(params::askedforhelp(cmdline, std::cout)){
return 0;
}
auto lang = params::getlanguage(cmdline);
if(lang.id == bin2hpp::lang_id::cpp) {
auto defaultsettings = bin2hpp::lang_options_cpp(lang._cpprev);
auto par = params::parsecmdlinecpp(cmdline, defaultsettings);
for (size_t i = 0; i != par.in.size(); i++) {
std::ifstream input(par.in.at(i), std::ifstream::binary);
std::ofstream output(par.out.at(i), std::ofstream::binary);
bin2hpp::create_file(input, par.langopt, par.names.at(i), output);
}
} else if(lang.id == bin2hpp::lang_id::c){
auto defaultsettings = bin2hpp::lang_options_c(lang._crev);
auto par = params::parsecmdlinec(cmdline, defaultsettings);
for (size_t i = 0; i != par.in.size(); i++) {
std::ifstream input(par.in.at(i), std::ifstream::binary);
std::ofstream output(par.out.at(i), std::ofstream::binary);
bin2hpp::create_file(input, par.langopt, par.names.at(i), output);
}
} else if(lang.id == bin2hpp::lang_id::java){
auto defaultsettings = bin2hpp::lang_options_java(lang._javarev);
auto par = params::parsecmdline_java(cmdline, defaultsettings);
for (size_t i = 0; i != par.in.size(); i++) {
std::ifstream input(par.in.at(i), std::ifstream::binary);
std::ofstream output(par.out.at(i), std::ofstream::binary);
bin2hpp::create_file(input, par.langopt, par.names.at(i), "", output);
}
} else {
assert(false && "unrecognized language");
}
return 0;
}