File tree Expand file tree Collapse file tree 2 files changed +6
-13
lines changed Expand file tree Collapse file tree 2 files changed +6
-13
lines changed Original file line number Diff line number Diff line change 3
3
4
4
#include < istream>
5
5
#include < string>
6
+ #include < string_view>
6
7
#include < toml++/toml.hpp>
7
8
8
9
#include " ../Processors.hpp"
@@ -25,18 +26,12 @@ auto read(InputVarType _var) {
25
26
return Parser<T, ProcessorsType>::read (r, _var);
26
27
}
27
28
28
- // / Reads a TOML string.
29
- template <class T , class ... Ps>
30
- Result<internal::wrap_in_rfl_array_t <T>> read (const std::string& _toml_str) {
31
- auto table = ::toml::parse (_toml_str);
32
- return read<T, Ps...>(&table);
33
- }
34
-
35
29
// / Reads a TOML string.
36
30
template <class T , class ... Ps>
37
31
Result<internal::wrap_in_rfl_array_t <T>> read (
38
32
const std::string_view _toml_str) {
39
- return read<T, Ps...>(std::string (_toml_str));
33
+ auto table = ::toml::parse (_toml_str);
34
+ return read<T, Ps...>(&table);
40
35
}
41
36
42
37
// / Parses an object from a stringstream.
Original file line number Diff line number Diff line change 12
12
#include " Parser.hpp"
13
13
#include " Reader.hpp"
14
14
15
- namespace rfl {
16
- namespace xml {
15
+ namespace rfl ::xml {
17
16
18
17
using InputVarType = typename Reader::InputVarType;
19
18
@@ -32,7 +31,7 @@ auto read(const InputVarType& _var) {
32
31
template <class T , class ... Ps>
33
32
Result<T> read (const std::string_view _xml_str) {
34
33
pugi::xml_document doc;
35
- const auto result = doc.load_string (_xml_str.data ());
34
+ const auto result = doc.load_buffer (_xml_str.data (), _xml_str. size ());
36
35
if (!result) {
37
36
return error (" XML string could not be parsed: " +
38
37
std::string (result.description ()));
@@ -49,7 +48,6 @@ auto read(std::istream& _stream) {
49
48
return read<T, Ps...>(xml_str);
50
49
}
51
50
52
- } // namespace xml
53
- } // namespace rfl
51
+ } // namespace rfl::xml
54
52
55
53
#endif
You can’t perform that action at this time.
0 commit comments