|
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 view over parsed row storage. | |
| CSVRow (internals::RawCSVDataPtr _data, size_t _data_start, size_t _field_bounds) | |
| CSVRow (internals::RawCSVDataPtr _data, size_t _data_start, size_t _field_bounds, size_t _row_length) | |
| 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. | |
| CSVField | operator[] (csv::string_view) const |
| Retrieve a value by its associated column name. | |
| std::string | to_json (const std::vector< std::string > &subset={}) const |
| std::string | to_json_array (const std::vector< std::string > &subset={}) const |
| const std::vector< std::string > & | get_col_names () const |
| Retrieve this row's associated column names. | |
| internals::ConstColNamesPtr | col_names_ptr () const noexcept |
| Internal accessor for preserving resolved column-name lookup policy across helper types. | |
| std::unordered_map< std::string, std::string > | to_unordered_map () const |
| Convert this CSVRow into an unordered map. | |
| std::unordered_map< std::string, std::string > | to_unordered_map (const std::vector< std::string > &subset) const |
| Convert a selected subset of columns into an unordered map. | |
| auto | to_sv_range () const |
| Convert this CSVRow into a std::ranges::input_range of string_views. | |
| operator std::vector< std::string > () const | |
Convert this row into a std::vector<std::string>. | |
| csv::string_view | raw_str () const noexcept |
| Return a string_view of the raw bytes of this row as they appear in the underlying parse buffer, up to (but not including) the trailing record terminator. | |
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. | |
| reverse_iterator | rbegin () const noexcept |
| reverse_iterator | rend () const |
Friends | |
| template<typename RowSink , typename ParsePolicy , typename FieldPolicy , typename RowPolicy > | |
| class | internals::CSVParserCore |
| struct | internals::CSVRowRowPolicy |
| struct | internals::speculative::CSVRowFragment |
Data structure for representing CSV rows.
Definition at line 544 of file csv_row.hpp.
| using csv::CSVRow::reverse_iterator = std::reverse_iterator<iterator> |
A reverse iterator over the contents of a CSVRow.
Definition at line 679 of file csv_row.hpp.
|
inline |
Construct a CSVRow view over parsed row storage.
Definition at line 555 of file csv_row.hpp.
|
inline |
Definition at line 556 of file csv_row.hpp.
|
inline |
Definition at line 558 of file csv_row.hpp.
| CSVRow::iterator csv::CSVRow::begin | ( | ) | const |
Return an iterator pointing to the first field.
Definition at line 186 of file csv_row.cpp.
|
inlinenoexcept |
Internal accessor for preserving resolved column-name lookup policy across helper types.
Definition at line 588 of file csv_row.hpp.
|
inlinenoexcept |
Indicates whether row is empty or not.
Definition at line 562 of file csv_row.hpp.
|
noexcept |
Return an iterator pointing to just after the end of the CSVRow.
Definition at line 195 of file csv_row.cpp.
|
inline |
Retrieve this row's associated column names.
Definition at line 583 of file csv_row.hpp.
| csv::CSVRow::operator std::vector< std::string > | ( | ) | const |
Convert this row into a std::vector<std::string>.
This conversion is primarily intended for write-side workflows, such as reordering or selecting columns before forwarding the row to CSVWriter.
operator[] because it materializes all fields as owning strings. | CSVField csv::CSVRow::operator[] | ( | csv::string_view | col_name | ) | const |
Retrieve a value by its associated column name.
If the column specified can't be round, a runtime error is thrown.
Definition at line 49 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 38 of file csv_row.cpp.
|
noexcept |
Return a string_view of the raw bytes of this row as they appear in the underlying parse buffer, up to (but not including) the trailing record terminator.
Definition at line 66 of file csv_row.cpp.
|
noexcept |
Definition at line 199 of file csv_row.cpp.
| CSVRow::reverse_iterator csv::CSVRow::rend | ( | ) | const |
Definition at line 203 of file csv_row.cpp.
|
inlinenoexcept |
Return the number of fields in this row.
Definition at line 565 of file csv_row.hpp.
|
inline |
Definition at line 571 of file csv_row.hpp.
|
inline |
Definition at line 576 of file csv_row.hpp.
|
inline |
Convert this CSVRow into a std::ranges::input_range of string_views.
Definition at line 607 of file csv_row.hpp.
| std::unordered_map< std::string, std::string > csv::CSVRow::to_unordered_map | ( | ) | const |
Convert this CSVRow into an unordered map.
Build a map from column names to values for a given row.
The keys are the column names and the values are the corresponding field values.
Definition at line 85 of file csv_row.cpp.
| std::unordered_map< std::string, std::string > csv::CSVRow::to_unordered_map | ( | const std::vector< std::string > & | subset | ) | const |
Convert a selected subset of columns into an unordered map.
Build a map from a subset of column names to values for a given row.
Definition at line 98 of file csv_row.cpp.
|
friend |
Definition at line 547 of file csv_row.hpp.
|
friend |
Definition at line 548 of file csv_row.hpp.
|
friend |
Definition at line 550 of file csv_row.hpp.