Gazebo Common

API Reference

6.0.0~pre2
CSVIStreamIterator Class Reference

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.
 
 CSVIStreamIterator (std::istream &_stream, const CSVDialect &_dialect=CSVDialect::Unix)
 Construct an iterator over _stream.
 
bool operator!= (const CSVIStreamIterator &_other) const
 Check for iterator inequality.
 
reference operator* () const
 Access current row.
 
CSVIStreamIteratoroperator++ ()
 Read the next row from the underlying stream.
 
CSVIStreamIterator operator++ (int)
 Read the next row from the underlying stream.
 
pointer operator-> () const
 Access current row.
 
bool operator== (const CSVIStreamIterator &_other) const
 Check for iterator equality.
 

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

◆ iterator_category

◆ pointer

using pointer = const value_type*

◆ reference

using reference = const value_type&

◆ value_type

Constructor & Destructor Documentation

◆ CSVIStreamIterator() [1/2]

Construct an end-of-stream iterator.

◆ CSVIStreamIterator() [2/2]

CSVIStreamIterator ( std::istream _stream,
const CSVDialect _dialect = CSVDialect::Unix 
)
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]_streamA stream of CSV data to iterate.
[in]_dialectCSV data dialect. Defaults to the Unix dialect.

Member Function Documentation

◆ operator!=()

bool operator!= ( const CSVIStreamIterator _other) const

Check for iterator inequality.

Parameters
[in]_otherIterator 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]_otherIterator 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: