diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-07-24 15:36:02 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-07-26 18:51:11 +0300 |
commit | acd95c325afaf09976400d86733d26b83f28542f (patch) | |
tree | 033ae91c626ffc99bc0527fd5878fed484016131 | |
parent | cb5f498dfeb0ec0ef86ac027b29cce6f2037fd3e (diff) | |
download | qtlocation-mapboxgl-acd95c325afaf09976400d86733d26b83f28542f.tar.gz |
[core] Fix issues with the std:: namespace and old compilers
Specifically when building Android with GCC 4.9 (which Qt still does :-/)
-rw-r--r-- | include/mbgl/util/string.hpp | 25 | ||||
-rw-r--r-- | src/mbgl/annotation/shape_annotation_impl.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/parser.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/sources/geojson_source_impl.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/text/shaping.cpp | 3 | ||||
-rw-r--r-- | src/mbgl/tile/geojson_tile.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/util/dtoa.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/util/http_header.cpp | 2 |
8 files changed, 39 insertions, 3 deletions
diff --git a/include/mbgl/util/string.hpp b/include/mbgl/util/string.hpp index de061647b5..82d317c620 100644 --- a/include/mbgl/util/string.hpp +++ b/include/mbgl/util/string.hpp @@ -1,9 +1,34 @@ #pragma once +#include <sstream> #include <string> #include <cassert> +#include <cstdlib> #include <exception> +// Polyfill needed by Qt when building for Android with GCC +#if defined(__ANDROID__) && defined(__GLIBCXX__) + +namespace std { + +template <typename T> +std::string to_string(T value) +{ + std::ostringstream oss; + oss << value; + + return oss.str(); +} + +inline int stoi(const std::string &str) +{ + return atoi(str.c_str()); +} + +} // namespace std + +#endif + namespace mbgl { namespace util { diff --git a/src/mbgl/annotation/shape_annotation_impl.hpp b/src/mbgl/annotation/shape_annotation_impl.hpp index ed9e8d015a..caf2cff1a5 100644 --- a/src/mbgl/annotation/shape_annotation_impl.hpp +++ b/src/mbgl/annotation/shape_annotation_impl.hpp @@ -1,5 +1,6 @@ #pragma once +#include <mbgl/util/string.hpp> #include <mapbox/geojsonvt.hpp> #include <mbgl/annotation/annotation.hpp> diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp index 467b44632c..a83897dbf5 100644 --- a/src/mbgl/style/parser.cpp +++ b/src/mbgl/style/parser.cpp @@ -8,6 +8,7 @@ #include <mbgl/style/conversion/light.hpp> #include <mbgl/util/logging.hpp> +#include <mbgl/util/string.hpp> #include <mapbox/geojsonvt.hpp> diff --git a/src/mbgl/style/sources/geojson_source_impl.cpp b/src/mbgl/style/sources/geojson_source_impl.cpp index be347af2ab..efa4018b46 100644 --- a/src/mbgl/style/sources/geojson_source_impl.cpp +++ b/src/mbgl/style/sources/geojson_source_impl.cpp @@ -1,10 +1,13 @@ #include <mbgl/style/sources/geojson_source_impl.hpp> #include <mbgl/util/constants.hpp> #include <mbgl/tile/tile_id.hpp> +#include <mbgl/util/string.hpp> #include <mapbox/geojsonvt.hpp> #include <supercluster.hpp> +#include <cmath> + namespace mbgl { namespace style { @@ -52,14 +55,14 @@ GeoJSONSource::Impl::Impl(const Impl& other, const GeoJSON& geoJSON) mapbox::supercluster::Options clusterOptions; clusterOptions.maxZoom = options.clusterMaxZoom; clusterOptions.extent = util::EXTENT; - clusterOptions.radius = std::round(scale * options.clusterRadius); + clusterOptions.radius = ::round(scale * options.clusterRadius); data = std::make_unique<SuperclusterData>( geoJSON.get<mapbox::geometry::feature_collection<double>>(), clusterOptions); } else { mapbox::geojsonvt::Options vtOptions; vtOptions.maxZoom = options.maxzoom; vtOptions.extent = util::EXTENT; - vtOptions.buffer = std::round(scale * options.buffer); + vtOptions.buffer = ::round(scale * options.buffer); vtOptions.tolerance = scale * options.tolerance; data = std::make_unique<GeoJSONVTData>(geoJSON, vtOptions); } diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index c81f25d4eb..6c7ecff42a 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -7,6 +7,7 @@ #include <boost/algorithm/string.hpp> #include <algorithm> +#include <cmath> namespace mbgl { @@ -72,7 +73,7 @@ float determineAverageLineWidth(const std::u16string& logicalInput, } } - int32_t targetLineCount = std::fmax(1, std::ceil(totalWidth / maxWidth)); + int32_t targetLineCount = ::fmax(1, std::ceil(totalWidth / maxWidth)); return totalWidth / targetLineCount; } diff --git a/src/mbgl/tile/geojson_tile.cpp b/src/mbgl/tile/geojson_tile.cpp index d5e2e14e54..f6861140b7 100644 --- a/src/mbgl/tile/geojson_tile.cpp +++ b/src/mbgl/tile/geojson_tile.cpp @@ -2,6 +2,7 @@ #include <mbgl/tile/geometry_tile_data.hpp> #include <mbgl/renderer/query.hpp> #include <mbgl/renderer/tile_parameters.hpp> +#include <mbgl/util/string.hpp> #include <mapbox/geojsonvt.hpp> #include <supercluster.hpp> diff --git a/src/mbgl/util/dtoa.cpp b/src/mbgl/util/dtoa.cpp index 6ca3e19c3d..0e3aef6117 100644 --- a/src/mbgl/util/dtoa.cpp +++ b/src/mbgl/util/dtoa.cpp @@ -6,6 +6,8 @@ #include <rapidjson/internal/dtoa.h> #endif +#include <mbgl/util/string.hpp> + namespace mbgl { namespace util { diff --git a/src/mbgl/util/http_header.cpp b/src/mbgl/util/http_header.cpp index 40711232ff..ce31a06c5e 100644 --- a/src/mbgl/util/http_header.cpp +++ b/src/mbgl/util/http_header.cpp @@ -1,5 +1,7 @@ #include <mbgl/util/http_header.hpp> +#include <mbgl/util/string.hpp> + #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunknown-pragmas" #pragma GCC diagnostic ignored "-Wunused-parameter" |