Merge pull request #521 from mapbox/no-boost-regex

Remove libboost_regex usage
This commit is contained in:
Konstantin Käfer
2014-10-30 11:35:01 -04:00
6 changed files with 22 additions and 43 deletions

View File

@@ -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

View File

@@ -1,38 +1,36 @@
#ifndef MBGL_UTIL_TOKEN
#define MBGL_UTIL_TOKEN
#ifdef __linux__
#include <boost/regex.hpp>
namespace regex_impl = boost;
#else
#include <regex>
namespace regex_impl = std;
#endif
#include <map>
#include <string>
#include <algorithm>
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 <typename Lookup>
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;

View File

@@ -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',

View File

@@ -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" \

View File

@@ -22,14 +22,6 @@
#include <locale>
#ifdef __linux__
#include <boost/regex.hpp>
namespace regex_impl = boost;
#else
#include <regex>
namespace regex_impl = std;
#endif
namespace mbgl {
// Note: This destructor is seemingly empty, but we need to declare it anyway

View File

@@ -10,11 +10,6 @@
'<@(curl_ldflags)',
'<@(png_ldflags)'
],
'conditions': [
['OS == "linux"', {
'ldflags':[ '-L<(boost_root)/lib','-lboost_regex' ]
}]
],
},
'targets': [
{ 'target_name': 'rotation_range',