Data inside a single cell, potentially stored as a reference to the original data.
More...
#include <csv_cell.h>
|
|
constexpr | CellReference ()=default |
| | Constructor, creates an Empty value.
|
| |
| template<typename BehaviorPolicy > |
| constexpr | CellReference (std::string_view cell, CellTypeHint hint, BehaviorPolicy policy) noexcept |
| | Constructor, which stores a copy or a reference to the original the cell data.
|
| |
|
constexpr CellType | getType () const |
| | Get data type.
|
| |
|
constexpr bool | isEmpty () const |
| | Check whether the data is of CellType::Empty type.
|
| |
| constexpr std::optional< double > | getDouble () const |
| | Get the cell value as a double.
|
| |
| constexpr std::optional< std::string_view > | getOriginalStringView (bool *has_escaped_quotes=nullptr) const |
| | Get stored data reference as string_view to the original CSV data.
|
| |
| std::optional< std::string > | getCleanString () const |
| | Get stored cell data as std::string.
|
| |
| template<std::size_t BufferSize> |
| constexpr CellStringBuffer< BufferSize > | getCleanStringBuffer () const |
| | Get a string buffer with collapsed consecutive double-quotes.
|
| |
| constexpr std::size_t | getRequiredBufferSize () const |
| | Get required buffer size to use as getCleanStringBuffer()'s template argument.
|
| |
Data inside a single cell, potentially stored as a reference to the original data.
If the cell type is CellType::String, this object references the data in original CSV text.
◆ CellReference()
template<typename BehaviorPolicy >
| constexpr Csv::CellReference::CellReference |
( |
std::string_view |
cell, |
|
|
CellTypeHint |
hint, |
|
|
BehaviorPolicy |
policy |
|
) |
| |
|
constexprnoexcept |
Constructor, which stores a copy or a reference to the original the cell data.
- Parameters
-
| cell | Cell data to store or reference. |
| hint | Type hint associated with the cell during parsing. |
| policy | Argument used for type inference. |
- Template Parameters
-
| BehaviorPolicy | Policy to use for parsing, same as BehaviorPolicy in Parser. |
◆ getCleanString()
| std::optional< std::string > Csv::CellReference::getCleanString |
( |
| ) |
const |
|
inline |
Get stored cell data 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.
◆ getCleanStringBuffer()
template<std::size_t BufferSize>
| constexpr CellStringBuffer< BufferSize > Csv::CellReference::getCleanStringBuffer |
( |
| ) |
const |
|
constexpr |
Get a string buffer with collapsed consecutive double-quotes.
This function is useful in constexpr context to retrieve unescaped cell data.
- Template Parameters
-
| BufferSize | buffer size has to be at least getOriginalStringView().size(). Note that buffer size is always checked, regardless of whether quotes had to be escaped or not. Reserving additional character for terminating null is not required. |
- Returns
- invalid buffer if BufferSize is too small.
◆ getDouble()
| constexpr std::optional< double > Csv::CellReference::getDouble |
( |
| ) |
const |
|
inlineconstexpr |
Get the cell value as a double.
This succeeds only if cell type is CellType::Double.
- Returns
std::nullopt on type mismatch.
◆ getOriginalStringView()
| constexpr std::optional< std::string_view > Csv::CellReference::getOriginalStringView |
( |
bool * |
has_escaped_quotes = nullptr | ) |
const |
|
inlineconstexpr |
Get stored data reference as string_view to the original CSV data.
This succeeds only if cell type is CellType::String.
- Parameters
-
| [out] | has_escaped_quotes | This cell may contain escaped consecutive double-quotes inside; if has_escaped_quotes is not std::nullptr, *has_escaped_quotes will reflect that. |
- Returns
std::nullopt on type mismatch.
◆ getRequiredBufferSize()
| constexpr std::size_t Csv::CellReference::getRequiredBufferSize |
( |
| ) |
const |
|
constexpr |
Get required buffer size to use as getCleanStringBuffer()'s template argument.
This function is useful in constexpr context.
The documentation for this class was generated from the following file:
- /home/runner/work/csv-parser/csv-parser/csv_parser/csv_cell.h