From 26f18861aa25b063845a95006055ca61c0fddeb1 Mon Sep 17 00:00:00 2001 From: Per-Arne Date: Mon, 20 Apr 2020 20:58:40 +0200 Subject: [PATCH] Added string parse functionality --- include/cpptoml.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/cpptoml.h b/include/cpptoml.h index 5a00da3..3b9ecc5 100644 --- a/include/cpptoml.h +++ b/include/cpptoml.h @@ -3231,6 +3231,21 @@ inline std::shared_ptr parse_file(const std::string& filename) return p.parse(); } + +/** + * Utility function to parse a file as a TOML file. Returns the root table. + * Throws a parse_exception if the file cannot be opened. + */ +inline std::shared_ptr
parse_string(const std::string& toml) + { + + std::stringstream data{toml}; + parser p{data}; + return p.parse(); + } + + + template struct value_accept;