File tree Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Expand file tree Collapse file tree 3 files changed +8
-3
lines changed Original file line number Diff line number Diff line change 6
6
#include < istream>
7
7
#include < string>
8
8
9
+ #include " ../internal/wrap_in_rfl_array_t.hpp"
9
10
#include " Parser.hpp"
10
11
#include " Reader.hpp"
11
12
@@ -24,9 +25,12 @@ auto read(const InputVarType& _obj) {
24
25
25
26
// / Parses an object from JSON using reflection.
26
27
template <class T >
27
- auto read (const std::string& _json_str) {
28
+ Result<internal:: wrap_in_rfl_array_t <T>> read (const std::string& _json_str) {
28
29
using PtrType = std::unique_ptr<yyjson_doc, void (*)(yyjson_doc*)>;
29
30
yyjson_doc* doc = yyjson_read (_json_str.c_str (), _json_str.size (), 0 );
31
+ if (!doc) {
32
+ return Error (" Could not parse document!" );
33
+ }
30
34
const auto ptr = PtrType (doc, yyjson_doc_free);
31
35
return read<T>(InputVarType (yyjson_doc_get_root (doc)));
32
36
}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ auto read(const InputVarType& _var) {
24
24
25
25
// / Parses an object from XML using reflection.
26
26
template <class T >
27
- auto read (const std::string& _xml_str) {
27
+ Result<T> read (const std::string& _xml_str) {
28
28
pugi::xml_document doc;
29
29
const auto result = doc.load_string (_xml_str.c_str ());
30
30
if (!result) {
Original file line number Diff line number Diff line change 6
6
#include < istream>
7
7
#include < string>
8
8
9
+ #include " ../internal/wrap_in_rfl_array_t.hpp"
9
10
#include " Parser.hpp"
10
11
#include " Reader.hpp"
11
12
@@ -23,7 +24,7 @@ auto read(const InputVarType& _var) {
23
24
24
25
// / Parses an object from YAML using reflection.
25
26
template <class T >
26
- auto read (const std::string& _yaml_str) {
27
+ Result<internal:: wrap_in_rfl_array_t <T>> read (const std::string& _yaml_str) {
27
28
try {
28
29
const auto var = InputVarType (YAML::Load (_yaml_str));
29
30
return read<T>(var);
You can’t perform that action at this time.
0 commit comments