|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
A CSV row with header-based field access. More...
#include <parse-csv.H>
Public Member Functions | |
| CsvRow (Array< std::string > fields) | |
| Construct from fields only (no header access). | |
| CsvRow (Array< std::string > fields, const Array< std::string > &header) | |
| Construct with header reference for name-based access. | |
| const std::string & | operator[] (size_t index) const |
| Get field by index. | |
| const std::string & | operator[] (const std::string &column_name) const |
| Get field by column name. | |
| const std::string & | at (size_t index) const |
| Get field by index with bounds checking. | |
| bool | has_column (const std::string &column_name) const |
| Check if column exists. | |
| template<typename T > | |
| T | get (size_t index) const |
| Get field as numeric type. | |
| template<typename T > | |
| T | get (const std::string &column_name) const |
| Get field as numeric type by column name. | |
| size_t | size () const |
| Get number of fields. | |
| bool | empty () const |
| Check if row is empty. | |
| const Array< std::string > & | fields () const |
| Get underlying array. | |
| const Array< std::string > * | header () const |
| Get column names (if header set). | |
Private Attributes | |
| Array< std::string > | fields_ |
| const Array< std::string > * | header_ |
A CSV row with header-based field access.
CsvRow wraps an Array of strings and provides access to fields by column name in addition to index-based access.
Definition at line 600 of file parse-csv.H.
|
inlineexplicit |
Construct from fields only (no header access).
Definition at line 607 of file parse-csv.H.
Construct with header reference for name-based access.
Definition at line 611 of file parse-csv.H.
Get field by index with bounds checking.
Definition at line 636 of file parse-csv.H.
References fields_, and Aleph::Array< T >::size().
|
inline |
Check if row is empty.
Definition at line 671 of file parse-csv.H.
References fields_, and Aleph::Array< T >::size().
Get field as numeric type by column name.
Definition at line 662 of file parse-csv.H.
References Aleph::maps().
Get field as numeric type.
Definition at line 655 of file parse-csv.H.
References fields_, and Aleph::maps().
Check if column exists.
Definition at line 644 of file parse-csv.H.
References fields_, header_, Aleph::maps(), and Aleph::Array< T >::size().
Get field by column name.
| std::runtime_error | If no header is set. |
| std::out_of_range | If column name not found. |
Definition at line 623 of file parse-csv.H.
References fields_, header_, Aleph::maps(), and Aleph::Array< T >::size().
|
inline |
Get number of fields.
Definition at line 668 of file parse-csv.H.
References fields_, and Aleph::Array< T >::size().
|
private |
Definition at line 602 of file parse-csv.H.
Referenced by at(), empty(), fields(), get(), has_column(), operator[](), operator[](), and size().
Definition at line 603 of file parse-csv.H.
Referenced by has_column(), header(), and operator[]().