#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... 
 | 
|  | 
◆ readCSV()
      
        
          | CSV readCSV | ( | istream & | in | ) |  | 
      
 
Definition at line 18 of file csv2code.cc.
   23     if (line.size() < 2 || line[0] == 
'#') {
 
   26     string type, name, number, comment;
 
   27     stringstream sline(line);
 
   32     csv.
types.emplace_back(type);
 
   33     csv.
names.emplace_back(name);
 
   34     csv.
numbers.emplace_back(number);
 
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
std::vector< std::string > numbers
std::vector< std::string > types
std::vector< std::string > names
std::vector< std::string > comments
 
 
 
◆ main()
      
        
          | 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");