1 #include <mbgl/style/conversion.hpp> 2 #include <mbgl/style/rapidjson_conversion.hpp> 3 4 #include <string> 5 #include <sstream> 6 7 namespace mbgl { 8 namespace style { 9 namespace conversion { 10 11 template <class T, class...Args> convertJSON(const std::string & json,Error & error,Args &&...args)12optional<T> convertJSON(const std::string& json, Error& error, Args&&...args) { 13 JSDocument document; 14 document.Parse<0>(json.c_str()); 15 16 if (document.HasParseError()) { 17 std::stringstream message; 18 message << document.GetErrorOffset() << " - " << rapidjson::GetParseError_En(document.GetParseError()); 19 error = { message.str() }; 20 return {}; 21 } 22 23 return convert<T>(document, error, std::forward<Args>(args)...); 24 } 25 26 } // namespace conversion 27 } // namespace style 28 } // namespace mbgl 29