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, const std::unordered_map< std::string, std::string > *_edits, const KeyType *_key)
 Construct a DataFrameRow wrapper.
 
CSVField operator[] (const std::string &col) const
 Access a field by column name, checking edits first.
 
CSVField operator[] (size_t n) const
 Access a field by position (positional access never checks edits).
 
size_t size () const
 Get the number of fields in the row.
 
bool empty () const
 Check if the row is empty.
 
std::vector< std::string > get_col_names () const
 Get column names.
 
const CSVRowget_underlying_row () const
 Get the underlying CSVRow for compatibility.
 
const KeyType & get_key () const
 Get the key for this row (only valid for keyed DataFrames).
 
 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.
 

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 104 of file data_frame.hpp.

Constructor & Destructor Documentation

◆ DataFrameRow() [1/2]

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

Default constructor (creates an unbound proxy).

Definition at line 107 of file data_frame.hpp.

◆ DataFrameRow() [2/2]

template<typename KeyType >
csv::DataFrameRow< KeyType >::DataFrameRow ( const CSVRow _row,
const std::unordered_map< std::string, std::string > *  _edits,
const KeyType *  _key 
)
inline

Construct a DataFrameRow wrapper.

Definition at line 110 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 141 of file data_frame.hpp.

◆ get_col_names()

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

Get column names.

Definition at line 144 of file data_frame.hpp.

◆ get_key()

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

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

Definition at line 150 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 147 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 153 of file data_frame.hpp.

◆ operator[]() [1/2]

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

Access a field by column name, checking edits first.

Parameters
colColumn name
Returns
CSVField representing the field value (edited if present, otherwise original)

Definition at line 122 of file data_frame.hpp.

◆ operator[]() [2/2]

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

Access a field by position (positional access never checks edits).

Definition at line 133 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 138 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 174 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 179 of file data_frame.hpp.


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