summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-03-21 14:41:08 +0100
committerKonstantin Käfer <mail@kkaefer.com>2017-03-28 13:53:19 +0200
commit68e032e505e23811aec1f6079995709b3d2b9700 (patch)
tree80296f3dd19cc2855d4d364659d5ee58921ba11b
parent9b39013ce4c6f98590b80ced425e0a3bcdb3f77f (diff)
downloadqtlocation-mapboxgl-68e032e505e23811aec1f6079995709b3d2b9700.tar.gz
[core] Remove private header includes from CLI utilities
-rw-r--r--bin/offline.cpp1
-rw-r--r--bin/render.cpp15
-rw-r--r--cmake/offline.cmake2
-rw-r--r--cmake/render.cmake2
-rw-r--r--src/mbgl/util/url.cpp13
-rw-r--r--src/mbgl/util/url.hpp1
-rw-r--r--test/util/url.test.cpp18
7 files changed, 8 insertions, 44 deletions
diff --git a/bin/offline.cpp b/bin/offline.cpp
index 502561d0a1..ec2fb09096 100644
--- a/bin/offline.cpp
+++ b/bin/offline.cpp
@@ -1,7 +1,6 @@
#include <mbgl/util/default_styles.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/util/string.hpp>
-#include <mbgl/util/io.hpp>
#include <mbgl/storage/default_file_source.hpp>
diff --git a/bin/render.cpp b/bin/render.cpp
index d4090cfa9f..0af933475a 100644
--- a/bin/render.cpp
+++ b/bin/render.cpp
@@ -1,14 +1,12 @@
#include <mbgl/map/map.hpp>
#include <mbgl/map/backend_scope.hpp>
#include <mbgl/util/image.hpp>
-#include <mbgl/util/io.hpp>
#include <mbgl/util/run_loop.hpp>
#include <mbgl/gl/headless_backend.hpp>
#include <mbgl/gl/offscreen_view.hpp>
#include <mbgl/util/default_thread_pool.hpp>
#include <mbgl/storage/default_file_source.hpp>
-#include <mbgl/util/url.hpp>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
@@ -21,6 +19,7 @@ namespace po = boost::program_options;
#include <cstdlib>
#include <iostream>
+#include <fstream>
int main(int argc, char *argv[]) {
std::string style_path;
@@ -91,12 +90,12 @@ int main(int argc, char *argv[]) {
ThreadPool threadPool(4);
Map map(backend, mbgl::Size { width, height }, pixelRatio, fileSource, threadPool, MapMode::Still);
- if (util::isURL(style_path)) {
- map.setStyleURL(style_path);
- } else {
- map.setStyleJSON(mbgl::util::read_file(style_path));
+ if (style_path.find("://") == std::string::npos) {
+ style_path = std::string("file://") + style_path;
}
+ map.setStyleURL(style_path);
+
map.setClasses(classes);
map.setLatLngZoom({ lat, lon }, zoom);
@@ -117,7 +116,9 @@ int main(int argc, char *argv[]) {
exit(1);
}
- util::write_file(output, encodePNG(view.readStillImage()));
+ std::ofstream out(output, std::ios::binary);
+ out << encodePNG(view.readStillImage());
+ out.close();
loop.stop();
});
diff --git a/cmake/offline.cmake b/cmake/offline.cmake
index 23824e6bdf..d0124e661f 100644
--- a/cmake/offline.cmake
+++ b/cmake/offline.cmake
@@ -12,8 +12,6 @@ target_compile_options(mbgl-offline
)
target_include_directories(mbgl-offline
- PRIVATE include
- PRIVATE src # TODO: eliminate
PRIVATE platform/default
)
diff --git a/cmake/render.cmake b/cmake/render.cmake
index 395a106642..023b3c21e3 100644
--- a/cmake/render.cmake
+++ b/cmake/render.cmake
@@ -7,8 +7,6 @@ target_compile_options(mbgl-render
)
target_include_directories(mbgl-render
- PRIVATE include
- PRIVATE src # TODO: eliminate
PRIVATE platform/default
)
diff --git a/src/mbgl/util/url.cpp b/src/mbgl/util/url.cpp
index 3f36bc676f..1f6dab9639 100644
--- a/src/mbgl/util/url.cpp
+++ b/src/mbgl/util/url.cpp
@@ -66,19 +66,6 @@ std::string percentDecode(const std::string& input) {
return decoded;
}
-// Checks whether the input string contains ://, and the part before it is all alphanumeric ASCII.
-bool isURL(const std::string& input) {
- auto it = input.begin();
- // First character has to be alphabetic
- if (it == input.end() || !isAlphaCharacter(*it++)) return false;
- // The remaining characters of the scheme can be alphanumeric, or be one of +.-
- while (it != input.end() && isSchemeCharacter(*it)) ++it;
- // Check that :// follows
- return (it != input.end() && *it++ == ':') &&
- (it != input.end() && *it++ == '/') &&
- (it != input.end() && *it++ == '/');
-}
-
URL::URL(const std::string& str)
: query([&]() -> Segment {
const auto hashPos = str.find('#');
diff --git a/src/mbgl/util/url.hpp b/src/mbgl/util/url.hpp
index e361b07a7c..70fdfd8a36 100644
--- a/src/mbgl/util/url.hpp
+++ b/src/mbgl/util/url.hpp
@@ -8,7 +8,6 @@ namespace util {
std::string percentEncode(const std::string&);
std::string percentDecode(const std::string&);
-bool isURL(const std::string&);
// Class that holds position + lenth pairs for scheme, domain, path + query string of a URL.
class URL {
diff --git a/test/util/url.test.cpp b/test/util/url.test.cpp
index ca24a5949a..55d8af2811 100644
--- a/test/util/url.test.cpp
+++ b/test/util/url.test.cpp
@@ -6,24 +6,6 @@
using namespace mbgl::util;
-TEST(URL, isURL) {
- EXPECT_TRUE(isURL("mapbox://foo"));
- EXPECT_TRUE(isURL("mapbox://"));
- EXPECT_TRUE(isURL("mapbox-test-scheme://foo"));
- EXPECT_TRUE(isURL("mapbox+style://foo"));
- EXPECT_TRUE(isURL("mapbox-2.0://foo"));
- EXPECT_TRUE(isURL("mapbox99://foo"));
-
- EXPECT_FALSE(isURL("mapbox:/"));
- EXPECT_FALSE(isURL(" mapbox://"));
- EXPECT_FALSE(isURL("://"));
- EXPECT_FALSE(isURL("mapbox"));
- EXPECT_FALSE(isURL("mapbox:foo"));
- EXPECT_FALSE(isURL("mapbox:/foo"));
- EXPECT_FALSE(isURL("test/mapbox://foo"));
- EXPECT_FALSE(isURL("123://foo"));
-}
-
TEST(URL, Scheme) {
EXPECT_EQ(URL::Segment({ 0, 4 }), URL("http://example.com/test?query=foo").scheme);
EXPECT_EQ(URL::Segment({ 0, 4 }), URL("http://127.0.0.1:8080/test?query=foo").scheme);