mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-07 03:06:18 +08:00
More efficient way of parsing array-like data structures. (#98)
This commit is contained in:
@@ -82,6 +82,18 @@ struct Reader {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
template <class ArrayReader>
|
||||
std::optional<Error> read_array(const ArrayReader& _array_reader,
|
||||
const InputArrayType& _arr) const noexcept {
|
||||
for (auto& node : *_arr) {
|
||||
const auto err = _array_reader.read(&node);
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
template <class ObjectReader>
|
||||
std::optional<Error> read_object(const ObjectReader& _object_reader,
|
||||
InputObjectType _obj) const noexcept {
|
||||
@@ -100,14 +112,6 @@ struct Reader {
|
||||
return ptr;
|
||||
}
|
||||
|
||||
std::vector<InputVarType> to_vec(const InputArrayType& _arr) const noexcept {
|
||||
std::vector<InputVarType> vec;
|
||||
for (auto& node : *_arr) {
|
||||
vec.push_back(&node);
|
||||
}
|
||||
return vec;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
rfl::Result<T> use_custom_constructor(
|
||||
const InputVarType _var) const noexcept {
|
||||
|
||||
Reference in New Issue
Block a user