getNextCSV() to scan and store complete CSV lines.
More...
#include <CSV_line.h>
Public Member Functions | |
| CSV_line () | |
| Constructor. | |
| CSV_line (const std::string &str) | |
Constructor from string str. | |
| CSV_line (const char *pz_str, size_t n=0) | |
Constructor from pz_str. | |
| CSV_line (const CSV_line &) | |
| Copy constructor. | |
| void | setData (const std::string &str) |
Scans line str to extract all its CSV fields. | |
| void | setData (const char *pz_str, size_t n=0) |
Scans line pz_str to extract all its CSV fields. | |
Friends | |
| class | test_CSV |
getNextCSV() to scan and store complete CSV lines.
chop() out trailing CR+LF's.Definition at line 36 of file CSV_line.h.
| CSV_line::CSV_line | ( | ) | [inline] |
| CSV_line::CSV_line | ( | const std::string & | str | ) | [inline] |
| CSV_line::CSV_line | ( | const char * | pz_str, | |
| size_t | n = 0 | |||
| ) | [inline] |
| CSV_line::CSV_line | ( | const CSV_line & | ) | [inline] |
| int CSV_line::setData | ( | const std::string & | str | ) |
Scans line str to extract all its CSV fields.
"\n" (Line Feed).str.length() characters in str [ including char(0) ]."\n" (Line Feed) characters are interpreted as comma ',' separators."\n" (Line Feed) from the last CSV field."\r\n" from the last CSV field.
{{ // test::setData()
CSV_line csv; // 012 3 ...4. .......5.
// // [,,a,b,"c,d","e f ""g"\r\n]
csv.setData( ",,a,b,\"c,d\",\"e f \"\"g\"\r\n" );
assertTrue( csv[0] == "" ); // []
assertTrue( csv[1] == "" ); // []
assertTrue( csv[2] == "a" ); // [a]
assertTrue( csv[3] == "b" ); // [b]
assertTrue( csv[4] == "c,d" ); // [c,d]
assertTrue( csv[5] == "e f \"g" ); // [e f "g]
assertTrue( csv.size() == 6 );
}}
Definition at line 23 of file CSV_line.cpp.
| int CSV_line::setData | ( | const char * | pz_str, | |
| size_t | n = 0 | |||
| ) |
Scans line pz_str to extract all its CSV fields.
n <= 0 computes the length with strlen().n chars in pz_str [ including char(0) ]."\n" (Line Feed)."\n" (Line Feed) characters are interpreted as comma ',' separators."\n" (Line Feed) from the last CSV field."\r\n" from the last CSV field.
{{ // test::setData()
CSV_line csv; // 012 3 ...4. .......5.
// // [,,a,b,"c,d","e f ""g"\r\n]
csv.setData( ",,a,b,\"c,d\",\"e f \"\"g\"\r\n" );
assertTrue( csv[0] == "" ); // []
assertTrue( csv[1] == "" ); // []
assertTrue( csv[2] == "a" ); // [a]
assertTrue( csv[3] == "b" ); // [b]
assertTrue( csv[4] == "c,d" ); // [c,d]
assertTrue( csv[5] == "e f \"g" ); // [e f "g]
assertTrue( csv.size() == 6 );
}}
Definition at line 40 of file CSV_line.cpp.
friend class test_CSV [friend] |
Definition at line 44 of file CSV_line.h.
1.5.8