diff options
author | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-08-08 18:29:17 +0300 |
---|---|---|
committer | Bruno de Oliveira Abinader <bruno@mapbox.com> | 2018-08-08 19:03:55 +0300 |
commit | 20d21cb7bcc6fe7639f546c053cfac1145430c4c (patch) | |
tree | 0dd7019379f20501b1ae02cb5d4ba398c82b9fd1 /src/mbgl/util | |
parent | ca7ef2aac74dd2c2ba478aa04fa3159ca2653d26 (diff) | |
download | qtlocation-mapboxgl-20d21cb7bcc6fe7639f546c053cfac1145430c4c.tar.gz |
Revert "[core] Replace Boost.Spirit with std::regex in CacheControl::parse()"
This reverts commit 990b3b11b9427ffd86f693d3f4c3dd351891e5d0.
Diffstat (limited to 'src/mbgl/util')
-rw-r--r-- | src/mbgl/util/http_header.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/mbgl/util/http_header.cpp b/src/mbgl/util/http_header.cpp index da68b4a790..4d9e2bf84c 100644 --- a/src/mbgl/util/http_header.cpp +++ b/src/mbgl/util/http_header.cpp @@ -2,20 +2,34 @@ #include <mbgl/util/string.hpp> -#include <regex> +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wunused-parameter" +#pragma GCC diagnostic ignored "-Wshadow" +#pragma clang diagnostic push + +#pragma clang diagnostic ignored "-Wshorten-64-to-32" +#pragma clang diagnostic ignored "-Wunknown-warning-option" +#pragma clang diagnostic ignored "-Wtautological-constant-compare" +#include <boost/spirit/include/qi.hpp> +#include <boost/spirit/include/phoenix_core.hpp> +#include <boost/spirit/include/phoenix_operator.hpp> +#pragma clang diagnostic pop +#pragma GCC diagnostic pop namespace mbgl { namespace http { CacheControl CacheControl::parse(const std::string& value) { - std::regex maxAgeRegex(R"((?:[^"]*"[^"]*[^\\]")*[^"]*max-age[\s]*=[\s]*([\d]+).*)"); - std::smatch maxAgeMatch; + namespace qi = boost::spirit::qi; + namespace phoenix = boost::phoenix; CacheControl result; - result.mustRevalidate = value.find("must-revalidate") != std::string::npos; - if (std::regex_match(value, maxAgeMatch, maxAgeRegex) && maxAgeMatch.size() == 2) { - result.maxAge = ::atoll(maxAgeMatch[1].str().c_str()); - } + qi::phrase_parse(value.begin(), value.end(), ( + (qi::lit("must-revalidate") [ phoenix::ref(result.mustRevalidate) = true ]) | + (qi::lit("max-age") >> '=' >> qi::ulong_long [ phoenix::ref(result.maxAge) = qi::_1 ]) | + (*(('"' >> *(('\\' >> qi::char_) | (qi::char_ - '"')) >> '"') | (qi::char_ - '"' - ','))) + ) % ',', qi::ascii::space); return result; } |