MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::csv::SliceParser::FieldReader Struct Reference

#include <slice.hpp>

Collaboration diagram for mtcore::csv::SliceParser::FieldReader:

Public Types

using ReadElem = std::variant<RowEnd, Field>
 
using ErrType = ReadError
 

Public Member Functions

Result< Slice< const ReadElem >, ErrTyperead (Slice< ReadElem > out)
 

Public Attributes

FieldParser iter
 
bool rowEnd = false
 

Detailed Description

Definition at line 118 of file csv/slice.hpp.

Member Typedef Documentation

◆ ErrType

◆ ReadElem

Definition at line 119 of file csv/slice.hpp.

Member Function Documentation

◆ read()

Result< Slice< const ReadElem >, ErrType > mtcore::csv::SliceParser::FieldReader::read ( Slice< ReadElem > out)
inline

Definition at line 124 of file csv/slice.hpp.

124 {
125 RowField cur;
126 size_t read = 0;
127 if (!out.empty() && rowEnd) {
128 out[read++] = RowEnd{};
129 rowEnd = false;
130 }
131
132 while (read < out.len && iter.next().copy_if_present(cur)) {
133 out[read++] = cur.field;
134 if (cur.rowEnd) {
135 if (read < out.len) {
136 out[read++] = RowEnd{};
137 }
138 else {
139 rowEnd = true;
140 }
141 }
142 }
143
144 if (iter.error.has_value()) {
145 return error(iter.error.value());
146 }
147 return success(out.sub(0, read).to_const());
148 }
Success< void > success()
Creates a successful void Result object.
Definition result.hpp:398
Error< Underlying > error(Underlying err)
Creates an error.
Definition result.hpp:425
Result< Slice< const ReadElem >, ErrType > read(Slice< ReadElem > out)
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ iter

FieldParser mtcore::csv::SliceParser::FieldReader::iter

Definition at line 121 of file csv/slice.hpp.

◆ rowEnd

bool mtcore::csv::SliceParser::FieldReader::rowEnd = false

Definition at line 122 of file csv/slice.hpp.


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