15 template<
typename Field>
18 template<
typename Row>
20 : field_(row.try_field(index, error)), error_(&error) {}
22 template<
typename Consumer>
23 void with_view(Consumer&& consumer)
const {
26 if (!*error_) std::forward<Consumer>(consumer)(field_.get_sv());
38 template<
typename Row>
40 using field_type =
typename std::decay<decltype(std::declval<Row&>()
41 .try_field(
size_t{0}, std::declval<CSVError&>()))>::type;
48 using iterator_category = std::input_iterator_tag;
50 using difference_type = std::ptrdiff_t;
56 : owner_(owner), index_(index) {}
59 return field_value(*owner_->row_, index_, *owner_->error_);
63 if (!owner_->failed()) ++index_;
73 bool operator==(
const iterator& other)
const {
74 return owner_ == other.owner_
75 && (index_ == other.index_ || (owner_ && owner_->failed()));
78 bool operator!=(
const iterator& other)
const {
return !(*
this == other); }
86 : row_(&row), error_(&error) {
89 if (!record_valid(row, 0)) {
96 iterator begin()
const {
return iterator(
this, 0); }
97 iterator end()
const {
return iterator(
this, size_); }
101 static auto record_valid(
const T& row,
int) ->
decltype(row.is_valid(), bool()) {
102 return row.is_valid();
106 static bool record_valid(
const T&,
long) {
return true; }
108 bool failed()
const {
return static_cast<bool>(*error_); }
115 template<
typename Row>
116 CheckedFieldRange<Row> checked_field_range(Row& row, CSVError& error) {
117 return CheckedFieldRange<Row>(row, error);
Borrow a row and error state for synchronous, single-pass field access.
A standalone header file containing shared code.
Shared exception message templates and throw helpers.
The all encompassing namespace.
@ InvalidProxy
A proxy is unbound or a column proxy was invalidated by structural mutation.
A diagnostic whose text remains valid for the lifetime of the error.