summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2018-10-18 18:41:59 +0200
committerKonstantin Käfer <mail@kkaefer.com>2018-10-23 12:23:40 +0200
commit8bf66ef7a71ea220f2ed30ddd7feda28805dde41 (patch)
tree9d12b8b9c40b76a5334d00b145931151accdbb8e /platform
parent70d5972e104aac91f4198540d4af14562e92d555 (diff)
downloadqtlocation-mapboxgl-8bf66ef7a71ea220f2ed30ddd7feda28805dde41.tar.gz
[core] remove some uses of <iostream> and <sstream>
Diffstat (limited to 'platform')
-rw-r--r--platform/android/src/conversion/constant.cpp17
-rw-r--r--platform/node/test/js/map.test.js4
2 files changed, 15 insertions, 6 deletions
diff --git a/platform/android/src/conversion/constant.cpp b/platform/android/src/conversion/constant.cpp
index eaff434dbc..a609dc7c60 100644
--- a/platform/android/src/conversion/constant.cpp
+++ b/platform/android/src/conversion/constant.cpp
@@ -1,7 +1,7 @@
#include "constant.hpp"
#include "collection.hpp"
-#include <sstream>
+#include <mbgl/util/string.hpp>
namespace mbgl {
namespace android {
@@ -24,9 +24,18 @@ Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, std::stri
}
Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, Color>::operator()(jni::JNIEnv& env, const Color& value) const {
- std::stringstream sstream;
- sstream << "rgba(" << value.r << ", " << value.g << ", " << value.b << ", " << value.a << ")";
- return jni::Make<jni::String>(env, sstream.str());
+ std::string result;
+ result.reserve(32);
+ result += "rgba(";
+ result += util::toString(value.r);
+ result += ", ";
+ result += util::toString(value.g);
+ result += ", ";
+ result += util::toString(value.b);
+ result += ", ";
+ result += util::toString(value.a);
+ result += ")";
+ return jni::Make<jni::String>(env, result);
}
Result<jni::Local<jni::Object<>>> Converter<jni::Local<jni::Object<>>, style::expression::Formatted>::operator()(jni::JNIEnv& env, const style::expression::Formatted& value) const {
diff --git a/platform/node/test/js/map.test.js b/platform/node/test/js/map.test.js
index 4a71d72046..b21c1519e3 100644
--- a/platform/node/test/js/map.test.js
+++ b/platform/node/test/js/map.test.js
@@ -317,7 +317,7 @@ test('Map', function(t) {
t.throws(function() {
map.load('foo bar');
- }, /Failed to parse style: 1 - Invalid value./);
+ }, /Failed to parse style: Invalid value. at offset 1/);
t.throws(function() {
map.load('""');
@@ -349,7 +349,7 @@ test('Map', function(t) {
t.throws(function() {
map.load('invalid');
- }, /Failed to parse style: 0 - Invalid value./);
+ }, /Failed to parse style: Invalid value. at offset 0/);
});
t.test('accepts an empty stylesheet string', function(t) {