#ifndef MBGL_STYLE_VALUE #define MBGL_STYLE_VALUE #include #include #include #include namespace mbgl { typedef mapbox::util::variant Value; std::string toString(const Value &value); Value parseValue(const rapidjson::Value&); namespace util { inline bool parseNumericString(const std::string &str, double &result) { char *end = nullptr; const char *begin = str.c_str(); result = std::strtod(begin, &end); while (*end != '\0' && isspace(*end)) end++; // eat whitespace after the end return errno == 0 && end - begin == long(str.size()); } } template T toNumber(const Value &value) { if (value.is()) { double val; return util::parseNumericString(value.get(), val) ? val : 0; } else if (value.is()) return value.get(); else if (value.is()) return value.get(); else if (value.is()) return value.get(); else if (value.is()) return value.get(); else return 0; } } #endif