Vince's CSV Parser
Loading...
Searching...
No Matches
csv::DataFrameRow< KeyType > Class Template Reference

Proxy class that wraps a CSVRow and intercepts field access to check for edits. More...

#include <data_frame.hpp>

Public Member Functions

 DataFrameRow ()
 Default constructor (creates an unbound proxy).
 
 DataFrameRow (const CSVRow *_row, DataFrame< KeyType > *_frame, size_t _row_index, RowOverlay *_edits, const KeyType *_key)
 Construct a mutable DataFrameRow wrapper.
 
 DataFrameRow (const CSVRow *_row, const DataFrame< KeyType > *_frame, size_t _row_index, const RowOverlay *_edits, const KeyType *_key)
 Construct a read-only DataFrameRow wrapper.
 
DataFrameCell operator[] (const std::string &col)
 Access a field by column name, preserving edit support.
 
DataFrameCell operator[] (size_t n)
 Access a field by position, preserving edit support.
 
DataFrameCell operator[] (const std::string &col) const
 Access a field by column name, checking edits first.
 
DataFrameCell operator[] (size_t n) const
 Access a field by position, checking edits first.
 
size_t size () const
 Get the number of fields in the row.
 
bool empty () const
 Check if the row is empty.
 
const std::vector< std::string > & get_col_names () const
 Get column names.
 
const CSVRowget_underlying_row () const
 Get the underlying CSVRow for compatibility.
 
const KeyType & key () const
 Get the key for this row (only valid for keyed DataFrames).
 
bool erase ()
 Delete this row from the parent DataFrame.
 
 operator std::vector< std::string > () const
 Convert to vector of strings for CSVWriter compatibility.
 
std::string to_json (const std::vector< std::string > &subset={}) const
 Convert to JSON.
 
std::string to_json_array (const std::vector< std::string > &subset={}) const
 Convert to JSON array.
 
auto to_sv_range () const
 Convert this DataFrameRow into a std::ranges::input_range of strings, respecting the sparse overlay (edited values take precedence).
 

Detailed Description

template<typename KeyType>
class csv::DataFrameRow< KeyType >

Proxy class that wraps a CSVRow and intercepts field access to check for edits.

Provides transparent access to both original and edited cell values.

Definition at line 582 of file data_frame.hpp.

Constructor & Destructor Documentation

◆ DataFrameRow() [1/3]

template<typename KeyType >
csv::DataFrameRow< KeyType >::DataFrameRow ( )
inline

Default constructor (creates an unbound proxy).

Definition at line 585 of file data_frame.hpp.

◆ DataFrameRow() [2/3]

template<typename KeyType >
csv::DataFrameRow< KeyType >::DataFrameRow ( const CSVRow _row,
DataFrame< KeyType > *  _frame,
size_t  _row_index,
RowOverlay _edits,
const KeyType *  _key 
)
inline

Construct a mutable DataFrameRow wrapper.

Definition at line 588 of file data_frame.hpp.

◆ DataFrameRow() [3/3]

template<typename KeyType >
csv::DataFrameRow< KeyType >::DataFrameRow ( const CSVRow _row,
const DataFrame< KeyType > *  _frame,
size_t  _row_index,
const RowOverlay _edits,
const KeyType *  _key 
)
inline

Construct a read-only DataFrameRow wrapper.

Definition at line 597 of file data_frame.hpp.

Member Function Documentation

◆ empty()

template<typename KeyType >
bool csv::DataFrameRow< KeyType >::empty ( ) const
inline

Check if the row is empty.

Definition at line 629 of file data_frame.hpp.

◆ erase()

template<typename KeyType >
bool csv::DataFrameRow< KeyType >::erase ( )
inline

Delete this row from the parent DataFrame.

Structural mutation invalidates outstanding row and cell proxies.

Definition at line 644 of file data_frame.hpp.

◆ get_col_names()

template<typename KeyType >
const std::vector< std::string > & csv::DataFrameRow< KeyType >::get_col_names ( ) const
inline

Get column names.

Definition at line 632 of file data_frame.hpp.

◆ get_underlying_row()

template<typename KeyType >
const CSVRow & csv::DataFrameRow< KeyType >::get_underlying_row ( ) const
inline

Get the underlying CSVRow for compatibility.

Definition at line 635 of file data_frame.hpp.

◆ key()

template<typename KeyType >
const KeyType & csv::DataFrameRow< KeyType >::key ( ) const
inline

Get the key for this row (only valid for keyed DataFrames).

Definition at line 638 of file data_frame.hpp.

◆ operator std::vector< std::string >()

template<typename KeyType >
csv::DataFrameRow< KeyType >::operator std::vector< std::string > ( ) const
inline

Convert to vector of strings for CSVWriter compatibility.

Definition at line 653 of file data_frame.hpp.

◆ operator[]() [1/4]

template<typename KeyType >
DataFrameCell csv::DataFrameRow< KeyType >::operator[] ( const std::string &  col)
inline

Access a field by column name, preserving edit support.

Definition at line 606 of file data_frame.hpp.

◆ operator[]() [2/4]

template<typename KeyType >
DataFrameCell csv::DataFrameRow< KeyType >::operator[] ( const std::string &  col) const
inline

Access a field by column name, checking edits first.

Definition at line 616 of file data_frame.hpp.

◆ operator[]() [3/4]

template<typename KeyType >
DataFrameCell csv::DataFrameRow< KeyType >::operator[] ( size_t  n)
inline

Access a field by position, preserving edit support.

Definition at line 611 of file data_frame.hpp.

◆ operator[]() [4/4]

template<typename KeyType >
DataFrameCell csv::DataFrameRow< KeyType >::operator[] ( size_t  n) const
inline

Access a field by position, checking edits first.

Definition at line 621 of file data_frame.hpp.

◆ size()

template<typename KeyType >
size_t csv::DataFrameRow< KeyType >::size ( ) const
inline

Get the number of fields in the row.

Definition at line 626 of file data_frame.hpp.

◆ to_json()

template<typename KeyType >
std::string csv::DataFrameRow< KeyType >::to_json ( const std::vector< std::string > &  subset = {}) const
inline

Convert to JSON.

Definition at line 664 of file data_frame.hpp.

◆ to_json_array()

template<typename KeyType >
std::string csv::DataFrameRow< KeyType >::to_json_array ( const std::vector< std::string > &  subset = {}) const
inline

Convert to JSON array.

Definition at line 674 of file data_frame.hpp.

◆ to_sv_range()

template<typename KeyType >
auto csv::DataFrameRow< KeyType >::to_sv_range ( ) const
inline

Convert this DataFrameRow into a std::ranges::input_range of strings, respecting the sparse overlay (edited values take precedence).

Note
Requires C++20 or later.

Definition at line 689 of file data_frame.hpp.


The documentation for this class was generated from the following file: