|
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. | |
| size_t | byte_offset () const noexcept |
| Return the absolute byte offset where this row starts in the source. | |
Value Retrieval | |
| CSVField | operator[] (size_t n) const |
Return the field at n. | |
| CSVField | operator[] (csv::string_view col_name) const |
Return the field named col_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 686 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 170 of file csv_row.cpp.
|
inlinenoexcept |
Return the absolute byte offset where this row starts in the source.
Definition at line 568 of file csv_row.hpp.
|
inlinenoexcept |
Internal accessor for preserving resolved column-name lookup policy across helper types.
Definition at line 595 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 179 of file csv_row.cpp.
|
inline |
Retrieve this row's associated column names.
Definition at line 590 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 |
Return the field named col_name.
Throws std::runtime_error if the name is absent.
Definition at line 33 of file csv_row.cpp.
| CSVField csv::CSVRow::operator[] | ( | size_t | n | ) | const |
Return the field at n.
Throws std::runtime_error if the index is out of bounds.
Definition at line 29 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 50 of file csv_row.cpp.
|
noexcept |
Definition at line 183 of file csv_row.cpp.
| CSVRow::reverse_iterator csv::CSVRow::rend | ( | ) | const |
Definition at line 187 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 578 of file csv_row.hpp.
|
inline |
Definition at line 583 of file csv_row.hpp.
|
inline |
Convert this CSVRow into a std::ranges::input_range of string_views.
Definition at line 614 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 69 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 82 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.