mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 10:46:18 +08:00
@@ -29,9 +29,21 @@ auto read(InputVarType _var) {
|
|||||||
/// Reads a TOML string.
|
/// Reads a TOML string.
|
||||||
template <class T, class... Ps>
|
template <class T, class... Ps>
|
||||||
Result<internal::wrap_in_rfl_array_t<T>> read(
|
Result<internal::wrap_in_rfl_array_t<T>> read(
|
||||||
const std::string_view _toml_str) {
|
const std::string_view _toml_str) noexcept {
|
||||||
auto table = ::toml::parse(_toml_str);
|
#if TOML_EXCEPTIONS
|
||||||
return read<T, Ps...>(&table);
|
try {
|
||||||
|
auto table = ::toml::parse(_toml_str);
|
||||||
|
return read<T, Ps...>(&table);
|
||||||
|
} catch (const std::exception& e) {
|
||||||
|
return error(e.what());
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
auto result = ::toml::parse(_toml_str);
|
||||||
|
if (!result) {
|
||||||
|
return error(std::string(result.error().description()));
|
||||||
|
}
|
||||||
|
return read<T, Ps...>(&result.table());
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses an object from a stringstream.
|
/// Parses an object from a stringstream.
|
||||||
|
|||||||
Reference in New Issue
Block a user