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