One row of a tsv_document. A light view: copy it freely while the document, or any copy of it, is alive.
More...
#include <tsv.hpp>
|
| std::string_view | operator[] (std::string_view column) const |
| | The cell in a named column.
|
| |
| std::string_view | cell (std::size_t index) const |
| | The cell at a column index.
|
| |
| bool | has (std::string_view column) const |
| | Whether the document has a column and this row's cell in it is not empty.
|
| |
| template<typename T > |
| T | get (std::string_view column) const |
| | A typed value.
|
| |
| template<typename T > |
| T | get_or (std::string_view column, T fallback) const |
| | A typed value, or a fallback when the column is missing or the cell is empty.
|
| |
| std::vector< std::string_view > | list (std::string_view column, char separator=';') const |
| | Split a list cell.
|
| |
| std::size_t | line () const noexcept |
| | The 1-based line of this row in its source.
|
| |
| const std::string & | source () const noexcept |
| | The source of this row's document.
|
| |
| tsv_error | error (std::string_view column, const std::string &message) const |
| | An error located at this row.
|
| |
One row of a tsv_document. A light view: copy it freely while the document, or any copy of it, is alive.
Definition at line 289 of file tsv.hpp.
◆ cell()
| std::string_view dasmig::core::tsv_row::cell |
( |
std::size_t |
index | ) |
const |
|
inline |
The cell at a column index.
- Parameters
-
| index | 0-based column index. |
- Returns
- The cell text.
- Exceptions
-
| std::out_of_range | If index is not a column. |
Definition at line 701 of file tsv.hpp.
◆ error()
| tsv_error dasmig::core::tsv_row::error |
( |
std::string_view |
column, |
|
|
const std::string & |
message |
|
) |
| const |
|
inline |
An error located at this row.
- Parameters
-
| column | Column name, or empty for the whole row. |
| message | What is wrong. |
- Returns
- The error, for throwing.
Definition at line 379 of file tsv.hpp.
◆ get()
template<typename T >
| T dasmig::core::tsv_row::get |
( |
std::string_view |
column | ) |
const |
|
inline |
A typed value.
Integers are base 10; doubles are decimal or scientific and must be finite; bool accepts 1, 0, true and false; strings are returned as they are.
- Template Parameters
-
| T | Arithmetic type, bool, std::string or std::string_view. |
- Parameters
-
- Returns
- The value.
- Exceptions
-
| tsv_error | If the column is missing, the cell is empty, or the text is not a valid T. |
Definition at line 322 of file tsv.hpp.
◆ get_or()
template<typename T >
| T dasmig::core::tsv_row::get_or |
( |
std::string_view |
column, |
|
|
T |
fallback |
|
) |
| const |
|
inline |
A typed value, or a fallback when the column is missing or the cell is empty.
- Template Parameters
-
- Parameters
-
| column | Column name. |
| fallback | Value for a missing or empty cell. |
- Returns
- The value.
- Exceptions
-
Definition at line 340 of file tsv.hpp.
◆ has()
| bool dasmig::core::tsv_row::has |
( |
std::string_view |
column | ) |
const |
|
inline |
Whether the document has a column and this row's cell in it is not empty.
- Parameters
-
- Returns
- True when a value is present.
Definition at line 708 of file tsv.hpp.
◆ line()
| std::size_t dasmig::core::tsv_row::line |
( |
| ) |
const |
|
inlinenoexcept |
The 1-based line of this row in its source.
- Returns
- The line number.
Definition at line 714 of file tsv.hpp.
◆ list()
| std::vector< std::string_view > dasmig::core::tsv_row::list |
( |
std::string_view |
column, |
|
|
char |
separator = ';' |
|
) |
| const |
|
inline |
Split a list cell.
- Parameters
-
| column | Column name. |
| separator | List separator (; in the shipped data). |
- Returns
- The items; empty for an empty cell. Items are not trimmed.
- Exceptions
-
Definition at line 351 of file tsv.hpp.
◆ operator[]()
| std::string_view dasmig::core::tsv_row::operator[] |
( |
std::string_view |
column | ) |
const |
|
inline |
The cell in a named column.
- Parameters
-
- Returns
- The cell text (empty for a missing trailing cell).
- Exceptions
-
Definition at line 691 of file tsv.hpp.
◆ source()
| const std::string & dasmig::core::tsv_row::source |
( |
| ) |
const |
|
inlinenoexcept |
The source of this row's document.
- Returns
- File name or description.
Definition at line 716 of file tsv.hpp.
◆ tsv_document
The documentation for this class was generated from the following file: