|
Vince's CSV Parser
|
Data structure for representing CSV rows. More...
#include <csv_row.hpp>
Classes | |
| class | iterator |
| Iterator producing short-lived CSVField values with independent lazy conversion caches. More... | |
| class | reverse_iterator |
| Reverse field-value iterator available since C++11. More... | |
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. | |
| std::unordered_map< std::string, std::string > | try_to_unordered_map (CSVError &error) const |
| Materialize named values; unknown names or absent header positions report an error. | |
| std::unordered_map< std::string, std::string > | try_to_unordered_map (CSVError &error, const std::vector< std::string > &subset) const |
Value Retrieval | |
| CSVField | try_field (size_t index, CSVError &error) const |
| Checked field retrieval. | |
| CSVField | try_field (csv::string_view name, CSVError &error) const |
| 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 | try_to_json (const std::vector< std::string > &subset, CSVError &error) const |
| Serialize a subset, reporting unknown column names. | |
| std::string | try_to_json_array (const std::vector< std::string > &subset, CSVError &error) const |
| 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 | |
Iteration produces field values with independent conversion caches. | |
| iterator | begin () const noexcept |
| iterator | end () const noexcept |
| reverse_iterator | rbegin () const noexcept |
| reverse_iterator | rend () const noexcept |
Friends | |
| template<typename RowSink , typename ParsePolicy , typename FieldPolicy , typename RowPolicy > | |
| class | internals::CSVParserCore |
| struct | internals::CSVRowRowPolicy |
| struct | internals::data_frame::RowViewAccessor |
| struct | internals::speculative::CSVRowFragment |
Data structure for representing CSV rows.
Definition at line 533 of file csv_row.hpp.
|
inline |
Construct a CSVRow view over parsed row storage.
Definition at line 545 of file csv_row.hpp.
|
inline |
Definition at line 546 of file csv_row.hpp.
|
inline |
Definition at line 548 of file csv_row.hpp.
|
noexcept |
Definition at line 218 of file csv_row.cpp.
|
inlinenoexcept |
Return the absolute byte offset where this row starts in the source.
Definition at line 558 of file csv_row.hpp.
|
inlinenoexcept |
Internal accessor for preserving resolved column-name lookup policy across helper types.
Definition at line 624 of file csv_row.hpp.
|
inlinenoexcept |
Indicates whether row is empty or not.
Definition at line 552 of file csv_row.hpp.
|
noexcept |
Definition at line 222 of file csv_row.cpp.
|
inline |
Retrieve this row's associated column names.
Definition at line 619 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 37 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 30 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 75 of file csv_row.cpp.
|
noexcept |
Definition at line 226 of file csv_row.cpp.
|
noexcept |
Definition at line 230 of file csv_row.cpp.
|
inlinenoexcept |
Return the number of fields in this row.
Definition at line 555 of file csv_row.hpp.
|
inline |
Definition at line 604 of file csv_row.hpp.
|
inline |
Definition at line 610 of file csv_row.hpp.
|
inline |
Convert this CSVRow into a std::ranges::input_range of string_views.
Definition at line 647 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.
The keys are the column names and the values are the corresponding field values.
Definition at line 127 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.
Definition at line 134 of file csv_row.cpp.
| CSVField csv::CSVRow::try_field | ( | csv::string_view | name, |
| CSVError & | error | ||
| ) | const |
Definition at line 56 of file csv_row.cpp.
Checked field retrieval.
Inspect error before using the returned field. The field's view remains valid only while this row's storage is alive.
Definition at line 47 of file csv_row.cpp.
|
inline |
Serialize a subset, reporting unknown column names.
Definition at line 591 of file csv_row.hpp.
|
inline |
Definition at line 597 of file csv_row.hpp.
| std::unordered_map< std::string, std::string > csv::CSVRow::try_to_unordered_map | ( | CSVError & | error | ) | const |
Materialize named values; unknown names or absent header positions report an error.
Definition at line 93 of file csv_row.cpp.
| std::unordered_map< std::string, std::string > csv::CSVRow::try_to_unordered_map | ( | CSVError & | error, |
| const std::vector< std::string > & | subset | ||
| ) | const |
Definition at line 97 of file csv_row.cpp.
|
friend |
Definition at line 536 of file csv_row.hpp.
|
friend |
Definition at line 537 of file csv_row.hpp.
|
friend |
Definition at line 538 of file csv_row.hpp.
|
friend |
Definition at line 540 of file csv_row.hpp.