Parser to split CSV into rows and columns. More...
#include <PartialCsvParser.hpp>
Public Member Functions | |
| PartialCsvParser (const Memory::CsvConfig &csv_config, size_t parse_from=PARSE_FROM_BODY_BEGINNING, size_t parse_to=PARSE_TO_FILE_END) | |
| Constructor. More... | |
| ~PartialCsvParser () | |
| std::vector< std::string > | get_row () throw (PCPCsvError) |
| Returns an array of parsed columns. More... | |
Parser to split CSV into rows and columns.
|
inline |
Constructor.
| csv_config | Instance of Memory::CsvConfig or its child class. |
| parse_from | CSV file's approximate offset to start parsing. Must be no less than CsvConfig::body_offset(). parse_from = PARSE_FROM_BODY_BEGINNING has the same meaning with parse_from = CsvConfig::body_offset(). |
| parse_to | CSV file's approximate offset to stop parsing. Must be no less than parse_from and less than CsvConfig::filesize(). parse_to = PARSE_TO_FILE_END has the same meaning with parse_to = CsvConfig::filesize() - 1. |
In order to fully parse CSV lines without overlaps, parse_from and parse_to are interpreted with the following strategy.
<----—> means range from parse_from to parse_to.
(beginning of CSV) aaaaaaaaaaaaaaaa \0
<---><-----><-->
(1) (2) (3)
In this severe edge case, only (1), who covers the beginning of line, parses line "aaaaaaaaaaaaaaaa" to prevent overlap.
(beginning of CSV) aaaaaaaaaaaaa \n bbbbbbbbbbb \0
<---><--------> <--------->
(1) (2) (3)
In this case, (1) parses "aaaaaaaaaaaaa", (2) parses no line, and (3) parses "bbbbbbbbbbb".
(beginning of CSV) aaaaaaaaaaaaa \n bbbbbbbbbbb \0
<---><-----------><-------->
(1) (2) (3)
In this case, (1) parses "aaaaaaaaaaaaa", (2) parses "bbbbbbbbbbb", and (3) parses no line.
In short, partial parser who covers the beginning of a line parses the line.
|
inline |
|
inline | |||||||||||||
Returns an array of parsed columns.
Parses only around [parse_from, parse_to) specified in constructor is parsed.
retval.empty().
1.8.7