AnCH CSV library namespace.
More...
AnCH CSV library namespace.
CSV records reading and writing (RFC 4180). See AnCH CSV library documentation.
◆ ErrorCode
CSV error code
- Since
- 0.3
| Enumerator |
|---|
| INVALID_FORMAT | Invalid CSV: quote in an unquoted field, character after a closing quote, unterminated quoted field, CR without LF
|
| TOO_LARGE | Input larger than Options::maxSize , record larger than Options::maxRecordSize or with more than Options::maxColumns columns
|
| COLUMN_COUNT | Record without the number of columns of the first record (Options::sameColumnCount )
|
| UNKNOWN_COLUMN | Unknown column (objects mapping)
|
| MISSING_COLUMN | Missing required column (objects mapping)
|
| CONVERSION | Value conversion error (objects mapping)
|
| CONSTRAINT_VIOLATION | Field constraint violation (objects mapping, anch-val constraints)
|
◆ deserialize()
Read every object of a CSV input (small volumes, see records for large ones)
- Template Parameters
-
- Parameters
-
| values | the objects (replaced) |
| input | the input stream |
| options | the options |
- Exceptions
-
| CsvError | invalid record, conversion error or constraint violation |
- Since
- 0.3
◆ records()
Objects of a CSV input, read one by one without loading the whole input: for(const Pet& pet : anch::csv::records<Pet>(input))
- Template Parameters
-
- Parameters
-
| input | the input stream |
| options | the options |
- Returns
- the records (input range)
- Exceptions
-
| CsvError | invalid header, UNKNOWN_COLUMN , MISSING_COLUMN |
- Since
- 0.3
◆ serialize()
template<std::ranges::input_range R>
requires
anch::Described<std::remove_cvref_t<std::ranges::range_value_t<R>>>
Write objects: header (with Options::header , also when there is no object), then one record per object
- Template Parameters
-
| R | the range type (its values are described objects) |
- Parameters
-
| values | the objects |
| out | the output stream |
| options | the options |
- Exceptions
-
- Since
- 0.3