A single-pass row iterator on an input stream of CSV data. More...
#include <CSVStreams.hh>
Public Types | |
using | difference_type = std::ptrdiff_t |
using | iterator_category = std::input_iterator_tag |
using | pointer = const value_type * |
using | reference = const value_type & |
using | value_type = std::vector< std::string > |
Public Member Functions | |
CSVIStreamIterator () | |
Construct an end-of-stream iterator. More... | |
CSVIStreamIterator (std::istream &_stream, const CSVDialect &_dialect=CSVDialect::Unix) | |
Construct an iterator over _stream . More... | |
bool | operator!= (const CSVIStreamIterator &_other) const |
Check for iterator inequality. More... | |
reference | operator* () const |
Access current row. More... | |
CSVIStreamIterator & | operator++ () |
Read the next row from the underlying stream. More... | |
CSVIStreamIterator | operator++ (int) |
Read the next row from the underlying stream. More... | |
pointer | operator-> () const |
Access current row. More... | |
bool | operator== (const CSVIStreamIterator &_other) const |
Check for iterator equality. More... | |
Detailed Description
A single-pass row iterator on an input stream of CSV data.
Similar to std::istream_iterator, this iterator parses a stream of CSV data, one row at a time.
- See also
ParseCSVRow
.
Member Typedef Documentation
◆ difference_type
using difference_type = std::ptrdiff_t |
◆ iterator_category
◆ pointer
using pointer = const value_type* |
◆ reference
using reference = const value_type& |
◆ value_type
using value_type = std::vector<std::string> |
Constructor & Destructor Documentation
◆ CSVIStreamIterator() [1/2]
Construct an end-of-stream iterator.
◆ CSVIStreamIterator() [2/2]
|
explicit |
Construct an iterator over _stream
.
The first row will be read from the underlying stream to initialize the iterator. If there are parsing errors while reading, the underlying stream failbit
will be set.
- Parameters
-
[in] _stream A stream of CSV data to iterate. [in] _dialect CSV data dialect. Defaults to the Unix dialect.
Member Function Documentation
◆ operator!=()
bool operator!= | ( | const CSVIStreamIterator & | _other | ) | const |
Check for iterator inequality.
- Parameters
-
[in] _other Iterator to compare with.
- Returns
- true if both iterators are not equal, false otherwise.
◆ operator*()
reference operator* | ( | ) | const |
Access current row.
Behavior is undefined if the iterator is an end-of-stream iterator.
- Returns
- reference to the current row.
◆ operator++() [1/2]
CSVIStreamIterator& operator++ | ( | ) |
Read the next row from the underlying stream.
If the read fails, the iterator becomes an end-of-stream iterator. If there are parsing errors while reading, the underlying stream failbit
will be set. If the iterator already is an end-of-stream iterator, behavior is undefined.
- Returns
- A reference to the iterator once modified.
◆ operator++() [2/2]
CSVIStreamIterator operator++ | ( | int | ) |
Read the next row from the underlying stream.
If the read fails, the iterator becomes an end-of-stream iterator. If there are parsing errors while reading, the underlying stream failbit
will be set. If the iterator already is an end-of-stream iterator, behavior is undefined.
- Returns
- A copy of the iterator before modification. Note that, while an iterator copy retains its state, the underlying stream may still be advanced.
◆ operator->()
pointer operator-> | ( | ) | const |
Access current row.
Behavior is undefined if the iterator is an end-of-stream iterator.
- Returns
- pointer to the current row.
◆ operator==()
bool operator== | ( | const CSVIStreamIterator & | _other | ) | const |
Check for iterator equality.
- Parameters
-
[in] _other Iterator to compare with.
- Returns
- true if both iterators are end-of-stream iterators or if both iterator wrap the same stream and use the same dialect, false otherwise.
The documentation for this class was generated from the following file: