diff --git a/README.md b/README.md index 8d55c2ac3..325a9225a 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ implemented in C++11, currently targeting iOS, OS X, and Ubuntu Linux. - [`libuv 0.10+`](https://github.com/joyent/libuv) - [`glfw 3.1+`](http://www.glfw.org/) - [`libcurl`](http://curl.haxx.se/libcurl/) (depends on OpenSSL; Linux only) - - `libboost_regex` (Linux only) - Apple Command Line Tools (for build on OS X; available at [Apple Developer](https://developer.apple.com/downloads)) - `pkg-config` (for build only) - [Homebrew](http://brew.sh) (for build on OS X) @@ -85,11 +84,11 @@ Finally, install Boost. If you're running Ubuntu 12.04 or older, you need to ins sudo add-apt-repository --yes ppa:boost-latest/ppa sudo apt-get update - sudo apt-get install libboost1.55-dev libboost-regex1.55-dev + sudo apt-get install libboost1.55-dev Otherwise, you can just install - sudo apt-get install libboost-dev libboost-regex-dev + sudo apt-get install libboost-dev Once you're done installing the build dependencies, you can get started by running diff --git a/include/mbgl/util/token.hpp b/include/mbgl/util/token.hpp index 786654133..0f045f434 100644 --- a/include/mbgl/util/token.hpp +++ b/include/mbgl/util/token.hpp @@ -1,38 +1,36 @@ #ifndef MBGL_UTIL_TOKEN #define MBGL_UTIL_TOKEN -#ifdef __linux__ -#include -namespace regex_impl = boost; -#else -#include -namespace regex_impl = std; -#endif - #include +#include +#include namespace mbgl { namespace util { -namespace detail { -const regex_impl::regex tokenRegex("\\{([\\w-]+)\\}"); -const regex_impl::sregex_token_iterator tokensEnd = regex_impl::sregex_token_iterator(); -} - +// Replaces {tokens} in a string by calling the lookup function. template std::string replaceTokens(const std::string &source, const Lookup &lookup) { std::string result; result.reserve(source.size()); - bool token = false; - for (auto token_it = regex_impl::sregex_token_iterator(source.begin(), source.end(), - detail::tokenRegex, {-1, 1}); - token_it != detail::tokensEnd; ++token_it, token = !token) { - if (!token_it->matched) { - continue; - } + auto pos = source.begin(); + const auto end = source.end(); - result += token ? lookup(token_it->str()) : token_it->str(); + while (pos != end) { + auto brace = std::find(pos, end, '{'); + result.append(pos, brace); + pos = brace; + if (pos != end) { + for (brace++; brace != end && std::isalnum(*brace); brace++); + if (brace != end && *brace == '}') { + result.append(lookup({ pos + 1, brace })); + pos = brace + 1; + } else { + result.append(pos, brace); + pos = brace; + } + } } return result; diff --git a/linux/mapboxgl-app.gyp b/linux/mapboxgl-app.gyp index 75ad23552..913a1fac4 100644 --- a/linux/mapboxgl-app.gyp +++ b/linux/mapboxgl-app.gyp @@ -30,11 +30,6 @@ '<@(curl_ldflags)', '<@(zlib_ldflags)', ], - 'conditions': [ - ['OS == "linux"', { - 'libraries':[ '-L<(boost_root)/lib','-lboost_regex' ] - }] - ], 'dependencies': [ '../mapboxgl.gyp:mbgl-standalone', '../mapboxgl.gyp:mbgl-linux', diff --git a/scripts/travis_before_install.sh b/scripts/travis_before_install.sh index 2668a2ddb..cdeb63d97 100755 --- a/scripts/travis_before_install.sh +++ b/scripts/travis_before_install.sh @@ -21,7 +21,7 @@ if [[ ${TRAVIS_OS_NAME} == "linux" ]]; then mapbox_time "install_build_tools" \ sudo apt-get -y install git build-essential zlib1g-dev automake gdb \ libtool xutils-dev make cmake pkg-config python-pip \ - libboost1.55-dev libboost-regex1.55-dev libcurl4-openssl-dev \ + libboost1.55-dev libcurl4-openssl-dev \ libpng-dev libsqlite3-dev mapbox_time "install_mesa_deps" \ diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp index 72f97096a..e707cde62 100644 --- a/src/map/tile_parser.cpp +++ b/src/map/tile_parser.cpp @@ -22,14 +22,6 @@ #include -#ifdef __linux__ -#include -namespace regex_impl = boost; -#else -#include -namespace regex_impl = std; -#endif - namespace mbgl { // Note: This destructor is seemingly empty, but we need to declare it anyway diff --git a/test/test.gyp b/test/test.gyp index 0261df837..74f4139a9 100644 --- a/test/test.gyp +++ b/test/test.gyp @@ -10,11 +10,6 @@ '<@(curl_ldflags)', '<@(png_ldflags)' ], - 'conditions': [ - ['OS == "linux"', { - 'ldflags':[ '-L<(boost_root)/lib','-lboost_regex' ] - }] - ], }, 'targets': [ { 'target_name': 'rotation_range',