String data inside a single cell, stored as a reference to the original data.
More...
#include <csv_cell.h>
|
|
constexpr | CellStringReference ()=default |
| | Constructor, creates an empty string reference.
|
| |
| template<typename BehaviorPolicy > |
| constexpr | CellStringReference (std::string_view cell, CellTypeHint hint, BehaviorPolicy policy) noexcept |
| | Constructor, which stores a reference to the original cell data.
|
| |
| constexpr std::string_view | getOriginalStringView (bool *has_escaped_quotes=nullptr) const noexcept |
| | Get stored cell reference as string_view.
|
| |
| std::string | getCleanString () |
| | Get stored cell reference a 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.
|
| |
String data inside a single cell, stored as a reference to the original data.
All cell contents are treated as having CellType::String type. This may be useful if the CSV has string data without quotes.
- Note
- : Some members of this class are suitable for constexpr context (compile-time parsing).
◆ CellStringReference()
template<typename BehaviorPolicy >
| constexpr Csv::CellStringReference::CellStringReference |
( |
std::string_view |
cell, |
|
|
CellTypeHint |
hint, |
|
|
BehaviorPolicy |
policy |
|
) |
| |
|
constexprnoexcept |
Constructor, which stores a reference to the original cell data.
- Parameters
-
| cell | Cell data to 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::string Csv::CellStringReference::getCleanString |
( |
| ) |
|
|
inline |
Get stored cell reference a std::string.
Cell type is assumed to be CellType::String, regardless of auto-detected type. The string has collapsed consecutive double-quotes inside.
- Returns
- empty string on type mismatch.
◆ getCleanStringBuffer()
template<std::size_t BufferSize>
| constexpr CellStringBuffer< BufferSize > Csv::CellStringReference::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.
◆ getOriginalStringView()
| constexpr std::string_view Csv::CellStringReference::getOriginalStringView |
( |
bool * |
has_escaped_quotes = nullptr | ) |
const |
|
inlineconstexprnoexcept |
Get stored cell reference as string_view.
Cell type is assumed to be CellType::String, regardless of auto-detected type.
- 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. |
◆ getRequiredBufferSize()
| constexpr std::size_t Csv::CellStringReference::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