mirror of
https://github.com/red0124/ssp.git
synced 2025-12-14 21:59:55 +01:00
Fix handling of invalid conversion/split within parser, update parser tests
This commit is contained in:
@@ -88,14 +88,26 @@ public:
|
||||
return to_object<T>(get_next<Ts...>());
|
||||
}
|
||||
|
||||
// TODO make the method work with if valid() returns false
|
||||
size_t line() const {
|
||||
return valid() ? reader_.line_number_ - 1 : 0;
|
||||
}
|
||||
|
||||
template <typename T, typename... Ts>
|
||||
no_void_validator_tup_t<T, Ts...> get_next() {
|
||||
std::optional<std::string> error;
|
||||
|
||||
if (!eof_) {
|
||||
reader_.parse();
|
||||
if constexpr (throw_on_error) {
|
||||
try {
|
||||
reader_.parse();
|
||||
} catch (...) {
|
||||
read_line();
|
||||
throw;
|
||||
}
|
||||
} else {
|
||||
reader_.parse();
|
||||
}
|
||||
}
|
||||
|
||||
reader_.update();
|
||||
@@ -112,6 +124,17 @@ public:
|
||||
return {};
|
||||
}
|
||||
|
||||
if constexpr (throw_on_error) {
|
||||
try {
|
||||
auto value = reader_.converter_.template convert<T, Ts...>();
|
||||
read_line();
|
||||
return value;
|
||||
} catch (...) {
|
||||
read_line();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
auto value = reader_.converter_.template convert<T, Ts...>();
|
||||
|
||||
if (!reader_.converter_.valid()) {
|
||||
|
||||
@@ -162,7 +162,6 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
// TODO handle this efficiently (if multiline is enabled)
|
||||
void handle_error_unterminated_quote() {
|
||||
constexpr static auto error_msg = "unterminated quote";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user