csv-parser 1.1.0
Csv::Parser (csv-parser)
Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
Csv::CellValue Class Reference

Data inside a single cell, stored as a copy. More...

#include <csv_cell.h>

Public Member Functions

 CellValue ()=default
 Constructor, creates an Empty value.
 
template<typename BehaviorPolicy >
 CellValue (std::string_view cell, CellTypeHint hint, BehaviorPolicy policy)
 Constructor, which stores a copy of the cell data.
 
CellType getType () const
 Get cell type.
 
bool isEmpty () const
 Check whether the cell is of CellType::Empty type.
 
std::optional< double > getDouble () const
 Get the cell value if cell type is Double.
 
std::optional< std::string > getString () const
 Get stored cell value as std::string.
 

Detailed Description

Data inside a single cell, stored as a copy.

This object always owns its data and does not reference the original CSV text.

Constructor & Destructor Documentation

◆ CellValue()

template<typename BehaviorPolicy >
Csv::CellValue::CellValue ( std::string_view  cell,
CellTypeHint  hint,
BehaviorPolicy  policy 
)

Constructor, which stores a copy of the cell data.

Parameters
cellCell data to store.
hintType hint associated with the cell during parsing.
policyArgument used for type inference.
Template Parameters
BehaviorPolicyPolicy to use for parsing, same as BehaviorPolicy in Parser.

Member Function Documentation

◆ getDouble()

std::optional< double > Csv::CellValue::getDouble ( ) const
inline

Get the cell value if cell type is Double.

This succeeds only if cell type is CellType::Double.

Returns
std::nullopt on type mismatch.

◆ getString()

std::optional< std::string > Csv::CellValue::getString ( ) const
inline

Get stored cell value as std::string.

This succeeds only if cell type is CellType::String. The string has collapsed consecutive double-quotes inside.

Returns
std::nullopt on type mismatch.

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