csvpp 1.2.0
CSV parsing / writing libraries
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
csv::Reader::Row Class Reference

Represents a single row of CSV data. More...

#include <csv.hpp>

Classes

class  Iterator
 Iterates over the fields within a Row. More...
 
class  Range
 Helper class for iterating over a Row. Use Row::range to obtain. More...
 

Public Member Functions

template<typename T = std::string>
Row::Iterator< Tbegin ()
 
template<typename T = std::string>
Row::Iterator< Tend ()
 
template<typename T = std::string>
Range< Trange ()
 Range helper.
 
template<typename T = std::string>
read_field ()
 Read a single field from the row.
 
template<typename T >
Rowoperator>> (T &data)
 Read a single field from the row.
 
template<typename T = std::string, typename OutputIter >
void read (OutputIter it)
 Reads row into an output iterator.
 
template<typename T = std::string>
std::vector< Tread_vec ()
 Reads row into a std::vector.
 
template<typename ... Args>
std::tuple< Args... > read_tuple ()
 Reads row into a tuple.
 
template<typename ... Data>
void read_v (Data &... data)
 Reads row into variadic arguments.
 
bool end_of_row () const
 
 operator bool ()
 

Detailed Description

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

Member Function Documentation

◆ begin()

template<typename T = std::string>
Row::Iterator< T > csv::Reader::Row::begin ( )
inline
Template Parameters
TType to convert fields to. Defaults to std::string
Returns
Iterator to current field in row

◆ end()

template<typename T = std::string>
Row::Iterator< T > csv::Reader::Row::end ( )
inline
Template Parameters
TType 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>>()

template<typename T >
Row & csv::Reader::Row::operator>> ( T & data)
inline

Read a single field from the row.

Parameters
[out]dataVariable to to write field to. Will store a default initialized object if past the end of the row
Returns
This Row object
Exceptions
Parse_errorif error parsing field (only when not parsing in lenient mode)
IO_errorif error reading CSV data
Type_conversion_errorif error converting to type T. Caller may call this again with a different type to try again

◆ range()

template<typename T = std::string>
Range< T > csv::Reader::Row::range ( )
inline

Range helper.

Useful when iterating over a row and converting to a specific type

Template Parameters
TType to convert fields to. Defaults to std::string
Returns
A Range object containing begin and end methods corresponding to this Row

◆ read()

template<typename T = std::string, typename OutputIter >
void csv::Reader::Row::read ( OutputIter it)
inline

Reads row into an output iterator.

Template Parameters
TType to convert fields to. Defaults to std::string
Parameters
itan output iterator to receive the row data
Exceptions
Parse_errorif error parsing field (only when not parsing in lenient mode)
IO_errorif error reading CSV data
Type_conversion_errorif error converting to type T

◆ read_field()

template<typename T = std::string>
T csv::Reader::Row::read_field ( )
inline

Read a single field from the row.

Template Parameters
TType 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_errorif error parsing field (only when not parsing in lenient mode)
IO_errorif error reading CSV data
Type_conversion_errorif error converting to type T. Caller may call this again with a different type to try again

◆ read_tuple()

template<typename ... Args>
std::tuple< Args... > csv::Reader::Row::read_tuple ( )
inline

Reads row into a tuple.

Template Parameters
Argstypes 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
Parse_errorif error parsing field (only when not parsing in lenient mode)
IO_errorif error reading CSV data
Type_conversion_errorif error converting to specified types

◆ read_v()

template<typename ... Data>
void csv::Reader::Row::read_v ( Data &... data)
inline

Reads row into variadic arguments.

Parameters
[out]dataVariables to read into. If more parameters are passed than there are fields in the row, the remaining parameters will be default initialized
Exceptions
Parse_errorif error parsing field (only when not parsing in lenient mode)
IO_errorif error reading CSV data
Type_conversion_errorif error converting to specified types

◆ read_vec()

template<typename T = std::string>
std::vector< T > csv::Reader::Row::read_vec ( )
inline

Reads row into a std::vector.

Template Parameters
TType to convert fields to. Defaults to std::string
Returns
std::vector containing the fields from the Row
Exceptions
Parse_errorif error parsing field (only when not parsing in lenient mode)
IO_errorif error reading CSV data
Type_conversion_errorif error converting to type T

The documentation for this class was generated from the following file: