File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44#include < istream>
55#include < string>
6+ #include < string_view>
67#include < toml++/toml.hpp>
78
89#include " ../Processors.hpp"
@@ -25,18 +26,12 @@ auto read(InputVarType _var) {
2526 return Parser<T, ProcessorsType>::read (r, _var);
2627}
2728
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-
3529// / Reads a TOML string.
3630template <class T , class ... Ps>
3731Result<internal::wrap_in_rfl_array_t <T>> read (
3832 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);
4035}
4136
4237// / Parses an object from a stringstream.
Original file line number Diff line number Diff line change 1212#include " Parser.hpp"
1313#include " Reader.hpp"
1414
15- namespace rfl {
16- namespace xml {
15+ namespace rfl ::xml {
1716
1817using InputVarType = typename Reader::InputVarType;
1918
@@ -32,7 +31,7 @@ auto read(const InputVarType& _var) {
3231template <class T , class ... Ps>
3332Result<T> read (const std::string_view _xml_str) {
3433 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 ());
3635 if (!result) {
3736 return error (" XML string could not be parsed: " +
3837 std::string (result.description ()));
@@ -49,7 +48,6 @@ auto read(std::istream& _stream) {
4948 return read<T, Ps...>(xml_str);
5049}
5150
52- } // namespace xml
53- } // namespace rfl
51+ } // namespace rfl::xml
5452
5553#endif
You can’t perform that action at this time.
0 commit comments