Vince's CSV Parser
Loading...
Searching...
No Matches
csv_reader_iterator.cpp
Go to the documentation of this file.
1
5#include "csv_reader.hpp"
6
7namespace csv {
10 CSVRow row;
11 if (!this->read_row(row)) {
12 return this->end();
13 }
14 return CSVReader::iterator(this, std::move(row));
15 }
16
20 CSV_INLINE CSV_CONST CSVReader::iterator CSVReader::end() const noexcept {
21 return CSVReader::iterator();
22 }
23
25 // CSVReader::iterator //
27
28 CSV_INLINE CSVReader::iterator::iterator(CSVReader* _daddy, CSVRow&& _row) :
29 daddy(_daddy) {
30 row = std::move(_row);
31 }
32
41 if (!daddy->read_row(this->row)) {
42 this->daddy = nullptr; // this == end()
43 }
44
45 return *this;
46 }
47
50 auto temp = *this;
51 if (!daddy->read_row(this->row)) {
52 this->daddy = nullptr; // this == end()
53 }
54
55 return temp;
56 }
57}
An input iterator capable of handling large files.
iterator & operator++()
Pre-increment iterator.
Main class for parsing CSVs from files and in-memory sources.
CSV_CONST iterator end() const noexcept
A placeholder for the imaginary past the end row in a CSV.
bool read_row(CSVRow &row)
Retrieve rows as CSVRow objects, returning true if more rows are available.
iterator begin()
Return an iterator to the first row in the reader.
Data structure for representing CSV rows.
Definition csv_row.hpp:280
#define CSV_INLINE
Helper macro which should be #defined as "inline" in the single header version.
Definition common.hpp:26
Defines functionality needed for basic CSV parsing.
The all encompassing namespace.