Represents a single row of CSV data.
More...
#include <csv.hpp>
Represents a single row of CSV data.
A Row may be obtained from Reader::get_row or Reader::Iterator
- Warning
- Reader object must not be destroyed or read from during Row lifetime
◆ begin()
- Template Parameters
-
T | Type to convert fields to. Defaults to std::string |
- Returns
- Iterator to current field in row
◆ end()
- Template Parameters
-
T | Type to convert fields to. Defaults to std::string |
- Returns
- Iterator to end of row
◆ end_of_row()
bool csv::Reader::Row::end_of_row |
( |
| ) |
const |
|
inline |
- Returns
true
if the last field in the row has been read
◆ operator bool()
- Returns
true
if more fields can be read
◆ operator>>()
Read a single field from the row.
- Parameters
-
[out] | data | Variable to to write field to. Will store a default initialized object if past the end of the row |
- Returns
- This Row object
- Exceptions
-
Parse_error | if error parsing field (only when not parsing in lenient mode) |
IO_error | if error reading CSV data |
Type_conversion_error | if error converting to type T. Caller may call this again with a different type to try again |
◆ range()
Range< T > csv::Reader::Row::range |
( |
| ) |
|
|
inline |
Range helper.
Useful when iterating over a row and converting to a specific type
- Template Parameters
-
T | Type to convert fields to. Defaults to std::string |
- Returns
- A Range object containing begin and end methods corresponding to this Row
◆ read()
Reads row into an output iterator.
- Template Parameters
-
T | Type to convert fields to. Defaults to std::string |
- Parameters
-
it | an output iterator to receive the row data |
- Exceptions
-
◆ read_field()
template<typename T = std::string>
T csv::Reader::Row::read_field |
( |
| ) |
|
|
inline |
Read a single field from the row.
- Template Parameters
-
T | Type to convert fields to. Defaults to std::string |
- Returns
- The next field from the row, or a default-initialized object if past the end of the row
- Exceptions
-
Parse_error | if error parsing field (only when not parsing in lenient mode) |
IO_error | if error reading CSV data |
Type_conversion_error | if error converting to type T. Caller may call this again with a different type to try again |
◆ read_tuple()
std::tuple< Args... > csv::Reader::Row::read_tuple |
( |
| ) |
|
|
inline |
Reads row into a tuple.
- Template Parameters
-
Args | types to convert fields to |
- Returns
- std::tuple containing the fields from the Row. If Args contains more elements than there are fields in the row, the remaining elements of the tuple will be default initialized
- Exceptions
-
◆ read_v()
void csv::Reader::Row::read_v |
( |
Data &... | data | ) |
|
|
inline |
Reads row into variadic arguments.
- Parameters
-
[out] | data | Variables to read into. If more parameters are passed than there are fields in the row, the remaining parameters will be default initialized |
- Exceptions
-
◆ read_vec()
std::vector< T > csv::Reader::Row::read_vec |
( |
| ) |
|
|
inline |
Reads row into a std::vector.
- Template Parameters
-
T | Type to convert fields to. Defaults to std::string |
- Returns
- std::vector containing the fields from the Row
- Exceptions
-
The documentation for this class was generated from the following file: