Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
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}
void convertHeader(std::ostream &out, const Header &header)
void convertCSV(std::ostream &out, const CSV &csv)

◆ readCSV()

CSV readCSV ( std::istream & in)

Definition at line 19 of file csv2code.cc.

19 {
20 // format of the CSV is type,name,number,comment
21 CSV csv;
22 string line;
23 while (getline(in, line)) {
24 if (line.size() < 2 || line[0] == '#') {
25 continue;
26 }
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);
36 csv.comments.emplace_back(comment);
37 }
38 return csv;
39}
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition JString.hh:478
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