Jpp  master_rocky-40-g5f0272dcd
the software that should make you happy
Classes | Functions
csv2code.hh File Reference
#include <iostream>
#include <string>
#include <vector>

Go to the source code of this file.

Classes

struct  Header
 
struct  CSV
 

Functions

template<typename LANG >
void convertCSV (std::ostream &out, const CSV &csv)
 
template<typename LANG >
void convertHeader (std::ostream &out, const Header &header)
 
template<typename LANG >
void convert (std::ostream &out, const Header &header, const CSV &csv)
 
CSV readCSV (std::istream &in)
 

Function Documentation

◆ convertCSV()

template<typename LANG >
void convertCSV ( std::ostream &  out,
const CSV csv 
)

◆ convertHeader()

template<typename LANG >
void convertHeader ( std::ostream &  out,
const Header header 
)

◆ convert()

template<typename LANG >
void convert ( std::ostream &  out,
const Header header,
const CSV csv 
)

Definition at line 29 of file csv2code.hh.

29  {
30  convertHeader<LANG>(out, header);
31  convertCSV<LANG>(out, csv);
32 }

◆ readCSV()

CSV readCSV ( std::istream &  in)

Definition at line 18 of file csv2code.cc.

18  {
19  // format of the CSV is type,name,number,comment
20  CSV csv;
21  string line;
22  while (getline(in, line)) {
23  if (line.size() < 2 || line[0] == '#') {
24  continue;
25  }
26  string type, name, number, comment;
27  stringstream sline(line);
28  getline(sline, type, ',');
29  getline(sline, name, ',');
30  getline(sline, number, ',');
31  getline(sline, comment);
32  csv.types.emplace_back(type);
33  csv.names.emplace_back(name);
34  csv.numbers.emplace_back(number);
35  csv.comments.emplace_back(comment);
36  }
37  return csv;
38 }
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
Definition: csv2code.hh:15
std::vector< std::string > numbers
Definition: csv2code.hh:18
std::vector< std::string > types
Definition: csv2code.hh:16
std::vector< std::string > names
Definition: csv2code.hh:17
std::vector< std::string > comments
Definition: csv2code.hh:19