csvpp

csvpp Commit Details


Date:2014-03-25 22:50:00 (10 years 8 months ago)
Author:Natalie Adams
Branch:default
Commit:9d9ea90c82c8
Parents: 31ee6af03377
Message:bug with delimiter_char

Changes:
Minclude/csvpp.h (1 diff)
Mtests.cpp (7 diffs)

File differences

include/csvpp.h
2424
2525
2626
27
27
2828
2929
3030
// Adding support for custom delimiter character
// Based on the patch by Hanifa
// https://code.google.com/p/csvpp/issues/detail?id=2
RowReader(std::string delimiter_char = ",", bool skipheader=false,const char * newline="\n") : skipheader(skipheader), newline(newline) { }
RowReader(std::string delimiter_char = ",", bool skipheader=false,const char * newline="\n") : delimiter_char(delimiter_char), skipheader(skipheader), newline(newline) { }
void clear() { header.clear(); }
friend std::istream & operator>>(std::istream & os, RowReader & r);
friend std::ostream & operator<<(std::ostream & os, const RowWriter & r);
tests.cpp
88
99
1010
11
11
1212
1313
1414
......
2121
2222
2323
24
24
2525
2626
2727
......
3030
3131
3232
33
3334
3435
3536
......
5657
5758
5859
59
60
6061
6162
6263
......
6566
6667
6768
69
6870
6971
7072
......
9496
9597
9698
97
99
98100
99101
100102
......
103105
104106
105107
108
106109
107110
108111
int test = 1;
// Test 1
{
RowReader tmp;
RowReader tmp(",");
stringstream ss;
ss << "field1,field2,field3\r\n123,234,345\r\n999,000,111\r\n";
ss >> tmp;
case 0:
if (tmp["field1"] != "123")
{
cout << tmp["field1"] << endl;
cerr << tmp["field1"] << endl;
cerr << "Failed at row " << row << endl;
cerr << "Failed at test " << test << endl;
return 1;
case 1:
if (tmp["field1"] != "999")
{
cerr << tmp["field1"] << endl;
cerr << "Failed at row " << row << endl;
cerr << "Failed at test " << test << endl;
return 1;
case 0:
if (tmp["field1"] != "123")
{
cout << tmp["field1"] << endl;
cerr << tmp["field1"] << endl;
cerr << "Failed at row " << row << endl;
cerr << "Failed at test " << test << endl;
return 1;
case 1:
if (tmp["field1"] != "999")
{
cerr << tmp["field1"] << endl;
cerr << "Failed at row " << row << endl;
cerr << "Failed at test " << test << endl;
return 1;
case 0:
if (tmp["field1"] != "123")
{
cout << tmp["field1"] << endl;
cerr << tmp["field1"] << endl;
cerr << "Failed at row " << row << endl;
cerr << "Failed at test " << test << endl;
return 1;
case 1:
if (tmp["field1"] != "999")
{
cerr << tmp["field1"] << endl;
cerr << "Failed at row " << row << endl;
cerr << "Failed at test " << test << endl;
return 1;

Archive Download the corresponding diff file

Branches

Tags

Page rendered in 0.40133s using 14 queries.