13 namespace illumina {
namespace interop {
namespace io {
namespace table
26 std::getline(in, line);
27 std::istringstream sin(line);
29 while(std::getline(sin, cell,
','))
31 if(cell==
"") values.push_back(missing);
32 else values.push_back(util::lexical_cast<T>(cell));
43 T read_value(std::istream& in, std::string& buf,
const char delim=
',')
45 std::getline(in, buf, delim);
56 void read_value(std::istream& in,
T& dest, std::string& buf,
const char delim=
',')
58 std::getline(in, buf, delim);
69 void read_csv(std::istream& in, I beg, I end,
const char delim=
',')
72 for(;beg != end;++beg)
95 if(std::isnan(val))
return std::numeric_limits<float>::quiet_NaN();
105 if(std::isnan(val))
return std::numeric_limits<double>::quiet_NaN();
117 void write_csv(std::ostream& out, I beg, I end,
const char eol,
const size_t precision=10)
119 if(beg == end)
return;
120 std::ios::fmtflags previous_state( out.flags() );
123 for(;beg != end;++beg)
126 out <<
"," << std::setprecision(precision) <<
handle_nan(*beg);
130 if(eol !=
'\0') out << eol;
131 out.flags(previous_state);
141 void write_csv_line(std::ostream& out,
const std::vector<T>& values,
const size_t beg=0,
size_t last=0)
143 if(values.empty())
return;
144 if(last == 0) last = values.size();
147 write_csv(out, values.begin()+beg, values.begin()+std::min(last, values.size()),
'\n');
T read_value(std::istream &in, std::string &buf, const char delim=',')
Definition: csv_format.h:43
Definition: enum_description.h:15
void write_csv(std::ostream &out, I beg, I end, const char eol, const size_t precision=10)
Definition: csv_format.h:117
void read_csv_line(std::istream &in, std::vector< T > &values, const T missing=T())
Definition: csv_format.h:22
#define INTEROP_ASSERT(TST)
Definition: assert.h:21
const T & handle_nan(const T &val)
Definition: csv_format.h:84
void write_csv_line(std::ostream &out, const std::vector< T > &values, const size_t beg=0, size_t last=0)
Definition: csv_format.h:141
void read_csv(std::istream &in, I beg, I end, const char delim=',')
Definition: csv_format.h:69
Destination lexical_cast(const Source &src)
Definition: lexical_cast.h:264