Vince's CSV Parser
Loading...
Searching...
No Matches
csv::DataFrameCell Class Reference

Inherits csv::CSVField.

Public Member Functions

 DataFrameCell (const DataFrameCell &other)
 
 DataFrameCell (DataFrameCell &&other) noexcept
 
 DataFrameCell (const CSVRow *_row, RowOverlay *_row_overlay, size_t _col_index)
 
 DataFrameCell (const CSVRow *_row, const RowOverlay *_row_overlay, size_t _col_index)
 
DataFrameCell & operator= (const DataFrameCell &other)
 
DataFrameCell & operator= (DataFrameCell &&other) noexcept
 
DataFrameCell & operator= (csv::string_view value)
 
bool try_assign (csv::string_view value, CSVError &error)
 Assign through a mutable cell, preserving the current value on validation failure.
 
template<typename T = std::string>
T get () const
 Const-friendly read access for proxy use in column iteration and callbacks.
 
bool is_null () const noexcept
 
bool is_str () const noexcept
 
bool is_num () const noexcept
 
bool is_int () const noexcept
 
bool is_float () const noexcept
 
DataType type () const noexcept
 
template<typename T >
bool try_get (T &out) const noexcept
 
template<typename T >
bool try_get (T &out, CSVConversionError &error) const noexcept
 
template<typename T = std::string>
T get () const
 Returns the value casted to the requested type, performing type checking before.
 
template<>
long double get () const
 Retrieve this field's value as a long double.
 
CONSTEXPR csv::string_view get_sv () const noexcept
 Return a string view over the field's contents.
 
bool is_float () const noexcept
 Returns true if field is a floating point value.
 
bool is_int () const noexcept
 Returns true if field is an integer.
 
bool is_null () const noexcept
 Returns true if field is an empty string or string of whitespace characters.
 
bool is_num () const noexcept
 Returns true if field is an integer or float.
 
bool is_str () const noexcept
 Returns true if field is a non-numeric, non-empty string.
 
template<typename T = std::string>
bool try_get (T &out) const noexcept
 Non-throwing equivalent of get().
 
template<typename T >
bool try_get (T &out, CSVConversionError &error) const noexcept
 Convert with the same rules as try_get(), retaining the failure reason.
 
DataType type () const noexcept
 Return the type of the underlying CSV data.
 
- Public Member Functions inherited from csv::CSVField
constexpr CSVField (csv::string_view _sv) noexcept
 Constructs a CSVField from a string_view.
 
 CSVField (csv::string_view _sv, const internals::CSVFieldScalar &scalar) noexcept
 
 operator csv::string_view () const noexcept
 
 operator std::string () const
 
template<typename T = std::string>
T get () const
 Returns the value casted to the requested type, performing type checking before.
 
template<typename T = std::string>
std::expected< T, CSVConversionError > as () const
 Return this field as T, preserving conversion failure as CSVConversionError.
 
template<typename T = std::string>
bool try_get (T &out) const noexcept
 Non-throwing equivalent of get().
 
template<typename T >
bool try_get (T &out, CSVConversionError &error) const noexcept
 Convert with the same rules as try_get(), retaining the failure reason.
 
template<typename T >
 operator std::optional< T > () const
 Convert this field to std::optional<T>, returning std::nullopt when conversion fails.
 
template<typename T = long long>
bool try_parse_hex (T &parsedValue) const
 Parse a hexadecimal value, returning false if the value is not hex.
 
bool try_parse_decimal (long double &dVal, const char decimalSymbol='.')
 Attempts to parse a decimal (or integer) value using the given symbol, returning true if the value is numeric.
 
bool try_parse_timestamp (std::uint64_t &out) const noexcept
 Parse this field as Unix milliseconds.
 
template<typename T >
bool try_parse_timestamp (T &out) const noexcept
 Parse this field as Unix milliseconds in a 64-bit unsigned integer.
 
template<typename Rep , typename Period >
bool try_parse_timestamp (std::chrono::duration< Rep, Period > &out) const noexcept
 Parse this field as a timestamp duration since the Unix epoch.
 
template<typename Duration >
bool try_parse_timestamp (std::chrono::time_point< std::chrono::system_clock, Duration > &out) const noexcept
 Parse this field as a std::chrono::system_clock time point.
 
template<typename T >
bool operator== (T other) const noexcept
 Compares the contents of this field to a numeric value.
 
CONSTEXPR csv::string_view get_sv () const noexcept
 Return a string view over the field's contents.
 
bool is_null () const noexcept
 Returns true if field is an empty string or string of whitespace characters.
 
bool is_str () const noexcept
 Returns true if field is a non-numeric, non-empty string.
 
bool is_num () const noexcept
 Returns true if field is an integer or float.
 
bool is_int () const noexcept
 Returns true if field is an integer.
 
bool is_float () const noexcept
 Returns true if field is a floating point value.
 
bool is_bool () const noexcept
 Returns true if field is a boolean value.
 
bool is_timestamp () const noexcept
 Returns true if field is a timestamp value.
 
DataType type () const noexcept
 Return the type of the underlying CSV data.
 
template<>
long double get () const
 Retrieve this field's value as a long double.
 
template<>
CONSTEXPR bool operator== (const char *other) const noexcept
 Compares the contents of this field to a string.
 
template<>
CONSTEXPR bool operator== (csv::string_view other) const noexcept
 Compares the contents of this field to a string.
 

Friends

template<typename KeyType >
class DataFrame
 

Detailed Description

Definition at line 14 of file data_frame_cell.hpp.

Constructor & Destructor Documentation

◆ DataFrameCell() [1/5]

csv::DataFrameCell::DataFrameCell ( )
inline

Definition at line 28 of file data_frame_cell.hpp.

◆ DataFrameCell() [2/5]

csv::DataFrameCell::DataFrameCell ( const DataFrameCell &  other)
inline

Definition at line 30 of file data_frame_cell.hpp.

◆ DataFrameCell() [3/5]

csv::DataFrameCell::DataFrameCell ( DataFrameCell &&  other)
inlinenoexcept

Definition at line 41 of file data_frame_cell.hpp.

◆ DataFrameCell() [4/5]

csv::DataFrameCell::DataFrameCell ( const CSVRow *  _row,
RowOverlay *  _row_overlay,
size_t  _col_index 
)
inline

Definition at line 52 of file data_frame_cell.hpp.

◆ DataFrameCell() [5/5]

csv::DataFrameCell::DataFrameCell ( const CSVRow *  _row,
const RowOverlay *  _row_overlay,
size_t  _col_index 
)
inline

Definition at line 64 of file data_frame_cell.hpp.

Member Function Documentation

◆ get() [1/3]

template<>
long double csv::CSVField::get ( ) const
inline

Retrieve this field's value as a long double.

Definition at line 892 of file csv_row.hpp.

◆ get() [2/3]

template<typename T = std::string>
T csv::CSVField::get ( ) const
inline

Returns the value casted to the requested type, performing type checking before.

Valid options for T
  • std::string or csv::string_view
  • signed integral types (signed char, short, int, long int, long long int)
  • unsigned integral types (unsigned char, unsigned short, unsigned int, unsigned long long)
  • floating point types (float, double, long double)
Invalid conversions
  • Converting non-numeric values to any numeric type
  • Converting floating point values to integers
  • Converting a large integer to a smaller type that will not hold it
Note
This method is capable of parsing scientific E-notation. See Scalar Conversion Reference for more details.
Exceptions
std::runtime_errorThrown if an invalid conversion is performed.
Warning
Currently, conversions to floating point types are not checked for loss of precision
Returned string views borrow the source text. Retain a row or field iterator for its parsing buffer, or request an owning std::string or numeric value.

Definition at line 140 of file csv_row.hpp.

◆ get() [3/3]

template<typename T = std::string>
T csv::DataFrameCell::get ( ) const
inline

Const-friendly read access for proxy use in column iteration and callbacks.

Definition at line 125 of file data_frame_cell.hpp.

◆ get_sv()

CONSTEXPR csv::string_view csv::CSVField::get_sv ( ) const
inlinenoexcept

Return a string view over the field's contents.

Definition at line 317 of file csv_row.hpp.

◆ is_float() [1/2]

bool csv::CSVField::is_float ( ) const
inlinenoexcept

Returns true if field is a floating point value.

Definition at line 336 of file csv_row.hpp.

◆ is_float() [2/2]

bool csv::DataFrameCell::is_float ( ) const
inlinenoexcept

Definition at line 146 of file data_frame_cell.hpp.

◆ is_int() [1/2]

bool csv::CSVField::is_int ( ) const
inlinenoexcept

Returns true if field is an integer.

Definition at line 331 of file csv_row.hpp.

◆ is_int() [2/2]

bool csv::DataFrameCell::is_int ( ) const
inlinenoexcept

Definition at line 142 of file data_frame_cell.hpp.

◆ is_null() [1/2]

bool csv::CSVField::is_null ( ) const
inlinenoexcept

Returns true if field is an empty string or string of whitespace characters.

Definition at line 320 of file csv_row.hpp.

◆ is_null() [2/2]

bool csv::DataFrameCell::is_null ( ) const
inlinenoexcept

Definition at line 130 of file data_frame_cell.hpp.

◆ is_num() [1/2]

bool csv::CSVField::is_num ( ) const
inlinenoexcept

Returns true if field is an integer or float.

Definition at line 326 of file csv_row.hpp.

◆ is_num() [2/2]

bool csv::DataFrameCell::is_num ( ) const
inlinenoexcept

Definition at line 138 of file data_frame_cell.hpp.

◆ is_str() [1/2]

bool csv::CSVField::is_str ( ) const
inlinenoexcept

Returns true if field is a non-numeric, non-empty string.

Definition at line 323 of file csv_row.hpp.

◆ is_str() [2/2]

bool csv::DataFrameCell::is_str ( ) const
inlinenoexcept

Definition at line 134 of file data_frame_cell.hpp.

◆ operator=() [1/3]

DataFrameCell & csv::DataFrameCell::operator= ( const DataFrameCell &  other)
inline

Definition at line 76 of file data_frame_cell.hpp.

◆ operator=() [2/3]

DataFrameCell & csv::DataFrameCell::operator= ( csv::string_view  value)
inline

Definition at line 105 of file data_frame_cell.hpp.

◆ operator=() [3/3]

DataFrameCell & csv::DataFrameCell::operator= ( DataFrameCell &&  other)
inlinenoexcept

Definition at line 90 of file data_frame_cell.hpp.

◆ try_assign()

bool csv::DataFrameCell::try_assign ( csv::string_view  value,
CSVError &  error 
)
inline

Assign through a mutable cell, preserving the current value on validation failure.

Definition at line 114 of file data_frame_cell.hpp.

◆ try_get() [1/4]

template<typename T = std::string>
bool csv::CSVField::try_get ( T &  out) const
inlinenoexcept

Non-throwing equivalent of get().

Applies the same type checks and conversions; returns true and writes to out on success, or returns false without throwing.

See also
get() for the full description of valid types, conversion rules, and warnings.

Example:

int value;
if (field.try_get(value)) {
// Use value safely
} else {
// Handle conversion failure
}

Definition at line 188 of file csv_row.hpp.

◆ try_get() [2/4]

template<typename T >
bool csv::DataFrameCell::try_get ( T &  out) const
inlinenoexcept

Definition at line 155 of file data_frame_cell.hpp.

◆ try_get() [3/4]

template<typename T >
bool csv::CSVField::try_get ( T &  out,
CSVConversionError &  error 
) const
inlinenoexcept

Convert with the same rules as try_get(), retaining the failure reason.

On failure, out is unchanged and error identifies the conversion failure.

Definition at line 197 of file csv_row.hpp.

◆ try_get() [4/4]

template<typename T >
bool csv::DataFrameCell::try_get ( T &  out,
CSVConversionError &  error 
) const
inlinenoexcept

Definition at line 160 of file data_frame_cell.hpp.

◆ type() [1/2]

DataType csv::CSVField::type ( ) const
inlinenoexcept

Return the type of the underlying CSV data.

Definition at line 345 of file csv_row.hpp.

◆ type() [2/2]

DataType csv::DataFrameCell::type ( ) const
inlinenoexcept

Definition at line 150 of file data_frame_cell.hpp.

Friends And Related Symbol Documentation

◆ DataFrame

template<typename KeyType >
friend class DataFrame
friend

Definition at line 165 of file data_frame_cell.hpp.


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