23 while (getline(in, line)) {
24 if (line.size() < 2 || line[0] ==
'#') {
27 string type, name, number, comment;
28 stringstream sline(line);
29 getline(sline, type,
',');
30 getline(sline, name,
',');
31 getline(sline, number,
',');
32 getline(sline, comment);
33 csv.
types.emplace_back(type);
34 csv.
names.emplace_back(name);
35 csv.
numbers.emplace_back(number);
47int main(
int argc,
char** argv) {
49 throw runtime_error(
"need at least 4 arguments");
51 string lang = argv[1];
53 string infile = argv[2];
54 string outfile = argv[3];
55 string base = argv[4];
57 argc > 5 ? argv[5] :
"some description";
58 string url = argc > 6 ? argv[6] :
"some url";
62 std::cerr <<
"Cannot open input file " << infile <<
"\n";
65 ofstream out(outfile);
67 std::cerr <<
"Cannot open output file " << outfile <<
"\n";
71 Header header{base, description, url};
76 }
else if (lang ==
"py") {
78 }
else if (lang ==
"jl") {
80 }
else if (lang ==
"sh") {
82 }
else if (lang ==
"csh") {
86 "unknown output language requested. I only know hh, py");
int main(int argc, char **argv)
Helper program to convert an input CSV file, with a format of #type,name,number,comment.
void convert(std::ostream &out, const Header &header, const CSV &csv)
std::vector< std::string > numbers
std::vector< std::string > types
std::vector< std::string > names
std::vector< std::string > comments