summaryrefslogtreecommitdiff
path: root/src/mbgl/util/dtoa.hpp
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2016-05-17 18:34:13 +0200
committerKonstantin Käfer <mail@kkaefer.com>2016-05-18 12:26:51 +0200
commitc5fc7f1980814a1063773e6c876dad66b7909adf (patch)
treeccfb86db993eca6b0ebc0b4df6f58ae80327e38f /src/mbgl/util/dtoa.hpp
parent002393bdead2f036982ea3adb8a13a3d58f3428a (diff)
downloadqtlocation-mapboxgl-c5fc7f1980814a1063773e6c876dad66b7909adf.tar.gz
[core] use rapidjson's dtoa implementation to stringify floating point numbers
Diffstat (limited to 'src/mbgl/util/dtoa.hpp')
-rw-r--r--src/mbgl/util/dtoa.hpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/mbgl/util/dtoa.hpp b/src/mbgl/util/dtoa.hpp
new file mode 100644
index 0000000000..00c2c25ce2
--- /dev/null
+++ b/src/mbgl/util/dtoa.hpp
@@ -0,0 +1,22 @@
+#ifndef MBGL_UTIL_DTOA
+#define MBGL_UTIL_DTOA
+
+#include <string>
+
+namespace mbgl {
+namespace util {
+
+char* dtoa(double value, char* buffer);
+
+inline std::string dtoa(double value) {
+ std::string data;
+ data.resize(25);
+ auto end = dtoa(value, const_cast<char*>(data.data()));
+ data.resize(end - data.data());
+ return data;
+}
+
+} // end namespace util
+} // end namespace mbgl
+
+#endif