Vince's CSV Parser
|
Data structure for representing CSV rows. More...
#include <csv_row.hpp>
Classes | |
class | iterator |
A random access iterator over the contents of a CSV row. More... | |
Public Types | |
using | reverse_iterator = std::reverse_iterator< iterator > |
A reverse iterator over the contents of a CSVRow. | |
Public Member Functions | |
CSVRow (internals::RawCSVDataPtr _data) | |
Construct a CSVRow from a RawCSVDataPtr. | |
CSVRow (internals::RawCSVDataPtr _data, size_t _data_start, size_t _field_bounds) | |
CONSTEXPR bool | empty () const noexcept |
Indicates whether row is empty or not. | |
CONSTEXPR size_t | size () const noexcept |
Return the number of fields in this row. | |
Value Retrieval | |
CSVField | operator[] (size_t n) const |
Return a CSVField object corrsponding to the nth value in the row. More... | |
CSVField | operator[] (const std::string &) const |
Retrieve a value by its associated column name. More... | |
std::string | to_json (const std::vector< std::string > &subset={}) const |
Convert a CSV row to a JSON object, i.e. More... | |
std::string | to_json_array (const std::vector< std::string > &subset={}) const |
Convert a CSV row to a JSON array, i.e. More... | |
std::vector< std::string > | get_col_names () const |
Retrieve this row's associated column names. | |
operator std::vector< std::string > () const | |
Convert this CSVRow into a vector of strings. More... | |
Iterators | |
Each iterator points to a CSVField object. | |
iterator | begin () const |
Return an iterator pointing to the first field. | |
iterator | end () const noexcept |
Return an iterator pointing to just after the end of the CSVRow. More... | |
reverse_iterator | rbegin () const noexcept |
reverse_iterator | rend () const |
Data structure for representing CSV rows.
Definition at line 304 of file csv_row.hpp.
|
noexcept |
Return an iterator pointing to just after the end of the CSVRow.
Definition at line 201 of file csv_row.cpp.
csv::CSVRow::operator std::vector< std::string > | ( | ) | const |
Convert this CSVRow into a vector of strings.
Note: This is a less efficient method of accessing data than using the [] operator.
CSVField csv::CSVRow::operator[] | ( | const std::string & | col_name | ) | const |
Retrieve a value by its associated column name.
If the column specified can't be round, a runtime error is thrown.
[in] | col_name | The column to look for |
Definition at line 47 of file csv_row.cpp.
CSVField csv::CSVRow::operator[] | ( | size_t | n | ) | const |
Return a CSVField object corrsponding to the nth value in the row.
std::runtime_error
if n is invalid.Definition at line 34 of file csv_row.cpp.
std::string csv::CSVRow::to_json | ( | const std::vector< std::string > & | subset = {} | ) | const |
Convert a CSV row to a JSON object, i.e.
{"col1":"value1","col2":"value2"}
[in] | subset | A subset of columns to contain in the JSON. Leave empty for original columns. |
Definition at line 199 of file csv_row_json.cpp.
std::string csv::CSVRow::to_json_array | ( | const std::vector< std::string > & | subset = {} | ) | const |
Convert a CSV row to a JSON array, i.e.
["value1","value2",...]
[in] | subset | A subset of columns to contain in the JSON. Leave empty for all columns. |
Definition at line 237 of file csv_row_json.cpp.