mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-11-29 22:36:19 +08:00
@@ -29,9 +29,21 @@ auto read(InputVarType _var) {
|
||||
/// Reads a TOML string.
|
||||
template <class T, class... Ps>
|
||||
Result<internal::wrap_in_rfl_array_t<T>> read(
|
||||
const std::string_view _toml_str) {
|
||||
auto table = ::toml::parse(_toml_str);
|
||||
return read<T, Ps...>(&table);
|
||||
const std::string_view _toml_str) noexcept {
|
||||
#if TOML_EXCEPTIONS
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user