#include "csv2code.hh"
#include <fstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <vector>
#include "csv2cpp.hh"
#include "csv2julia.hh"
#include "csv2python.hh"
#include "csv2shell.hh"
Go to the source code of this file.
|
CSV | readCSV (istream &in) |
|
int | main (int argc, char **argv) |
| Helper program to convert an input CSV file, with a format of type,name,number,comment. More...
|
|
CSV readCSV |
( |
istream & |
in | ) |
|
Definition at line 18 of file csv2code.cc.
23 if (line.size() < 2 || line[0] ==
'#') {
27 stringstream sline(line);
32 csv.
types.emplace_back(type);
33 csv.
names.emplace_back(name);
34 csv.
numbers.emplace_back(number);
std::vector< std::string > types
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
std::vector< std::string > numbers
then fatal The output file must have the wildcard in the name
std::vector< std::string > comments
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
then set_variable DETECTOR set_variable OUTPUT_FILE set_variable DAQ_FILE set_variable PMT_FILE else fatal Wrong number of arguments fi JPrintTree f $DAQ_FILE type
std::vector< std::string > names
int main |
( |
int |
argc, |
|
|
char ** |
argv |
|
) |
| |
Helper program to convert an input CSV file, with a format of type,name,number,comment.
into a source code file of the requested language.
Definition at line 46 of file csv2code.cc.
48 throw runtime_error(
"need at least 4 arguments");
50 string lang = argv[1];
52 string infile = argv[2];
53 string outfile = argv[3];
54 string base = argv[4];
56 argc > 5 ? argv[5] :
"some description";
57 string url = argc > 6 ? argv[6] :
"some url";
61 std::cerr <<
"Cannot open input file " << infile <<
"\n";
64 ofstream out(outfile);
66 std::cerr <<
"Cannot open output file " << outfile <<
"\n";
70 Header header{base, description, url};
74 convert<CPP>(out, header, csv);
75 }
else if (lang ==
"py") {
76 convert<PYTHON>(out, header, csv);
77 }
else if (lang ==
"jl") {
78 convert<JULIA>(out, header, csv);
79 }
else if (lang ==
"sh") {
80 convert<SHELL>(out, header, csv);
83 "unknown output language requested. I only know hh, py");
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in