Skip to content

Commit

Permalink
optional parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
felixguendling committed Mar 1, 2025
1 parent 368fdcb commit 1d9cc46
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/utl/parser/csv.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,16 @@ inline void parse_value(cstr& s, cista::raw::generic_string& arg) {
}
inline void parse_value(cstr& s, cstr& arg) { parse_arg(s, arg); }

template <typename T>
inline void parse_value(cstr& s, std::optional<T>& arg) {
if (s.trim().empty()) {
arg = std::nullopt;
} else {
arg = T{};
parse_value(s, *arg);
}
}

template <int Index, typename... Args>
typename std::enable_if<Index == sizeof...(Args)>::type read(
std::tuple<Args...>&, std::array<cstr, sizeof...(Args)>&) {}
Expand Down

0 comments on commit 1d9cc46

Please sign in to comment.