diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2018-10-18 18:41:59 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2018-10-23 12:23:40 +0200 |
commit | 8bf66ef7a71ea220f2ed30ddd7feda28805dde41 (patch) | |
tree | 9d12b8b9c40b76a5334d00b145931151accdbb8e /src | |
parent | 70d5972e104aac91f4198540d4af14562e92d555 (diff) | |
download | qtlocation-mapboxgl-8bf66ef7a71ea220f2ed30ddd7feda28805dde41.tar.gz |
[core] remove some uses of <iostream> and <sstream>
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/algorithm/generate_clip_ids.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/geometry/line_atlas.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/renderer/sources/render_raster_dem_source.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/sprite/sprite_parser.cpp | 5 | ||||
-rw-r--r-- | src/mbgl/storage/response.cpp | 25 | ||||
-rw-r--r-- | src/mbgl/style/conversion/json.hpp | 5 | ||||
-rw-r--r-- | src/mbgl/style/parser.cpp | 7 | ||||
-rw-r--r-- | src/mbgl/text/shaping.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/tile/geometry_tile.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/util/mapbox.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/util/rapidjson.cpp | 13 | ||||
-rw-r--r-- | src/mbgl/util/rapidjson.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/util/stopwatch.cpp | 1 | ||||
-rw-r--r-- | src/mbgl/util/stopwatch.hpp | 3 |
14 files changed, 22 insertions, 46 deletions
diff --git a/src/mbgl/algorithm/generate_clip_ids.cpp b/src/mbgl/algorithm/generate_clip_ids.cpp index 287d2a408e..aefa55b929 100644 --- a/src/mbgl/algorithm/generate_clip_ids.cpp +++ b/src/mbgl/algorithm/generate_clip_ids.cpp @@ -7,7 +7,6 @@ #include <vector> #include <bitset> #include <cassert> -#include <iostream> #include <algorithm> #include <iterator> diff --git a/src/mbgl/geometry/line_atlas.cpp b/src/mbgl/geometry/line_atlas.cpp index ba14655cab..1bd6f987e1 100644 --- a/src/mbgl/geometry/line_atlas.cpp +++ b/src/mbgl/geometry/line_atlas.cpp @@ -4,7 +4,6 @@ #include <mbgl/util/platform.hpp> #include <mbgl/util/hash.hpp> -#include <sstream> #include <cmath> namespace mbgl { diff --git a/src/mbgl/renderer/sources/render_raster_dem_source.cpp b/src/mbgl/renderer/sources/render_raster_dem_source.cpp index fbf2c09d19..2283a0e788 100644 --- a/src/mbgl/renderer/sources/render_raster_dem_source.cpp +++ b/src/mbgl/renderer/sources/render_raster_dem_source.cpp @@ -4,7 +4,6 @@ #include <mbgl/algorithm/update_tile_masks.hpp> #include <mbgl/geometry/dem_data.hpp> #include <mbgl/renderer/buckets/hillshade_bucket.hpp> -#include <iostream> namespace mbgl { diff --git a/src/mbgl/sprite/sprite_parser.cpp b/src/mbgl/sprite/sprite_parser.cpp index 1a36e3e990..99e2b0c8ca 100644 --- a/src/mbgl/sprite/sprite_parser.cpp +++ b/src/mbgl/sprite/sprite_parser.cpp @@ -9,7 +9,6 @@ #include <cmath> #include <limits> -#include <sstream> namespace mbgl { @@ -91,9 +90,7 @@ std::vector<std::unique_ptr<style::Image>> parseSprite(const std::string& encode JSDocument doc; doc.Parse<0>(json.c_str()); if (doc.HasParseError()) { - std::stringstream message; - message << "Failed to parse JSON: " << rapidjson::GetParseError_En(doc.GetParseError()) << " at offset " << doc.GetErrorOffset(); - throw std::runtime_error(message.str()); + throw std::runtime_error("Failed to parse JSON: " + formatJSONParseError(doc)); } else if (!doc.IsObject()) { throw std::runtime_error("Sprite JSON root must be an object"); } else { diff --git a/src/mbgl/storage/response.cpp b/src/mbgl/storage/response.cpp index 222f55db84..ba075c3262 100644 --- a/src/mbgl/storage/response.cpp +++ b/src/mbgl/storage/response.cpp @@ -1,8 +1,4 @@ #include <mbgl/storage/response.hpp> -#include <mbgl/util/chrono.hpp> - -#include <iostream> -#include <cassert> namespace mbgl { @@ -26,25 +22,4 @@ Response::Error::Error(Reason reason_, std::string message_, optional<Timestamp> : reason(reason_), message(std::move(message_)), retryAfter(std::move(retryAfter_)) { } -std::ostream& operator<<(std::ostream& os, Response::Error::Reason r) { - switch (r) { - case Response::Error::Reason::Success: - return os << "Response::Error::Reason::Success"; - case Response::Error::Reason::NotFound: - return os << "Response::Error::Reason::NotFound"; - case Response::Error::Reason::Server: - return os << "Response::Error::Reason::Server"; - case Response::Error::Reason::Connection: - return os << "Response::Error::Reason::Connection"; - case Response::Error::Reason::RateLimit: - return os << "Response::Error::Reason::RateLimit"; - case Response::Error::Reason::Other: - return os << "Response::Error::Reason::Other"; - } - - // The above switch is exhaustive, but placate GCC nonetheless: - assert(false); - return os; -} - } // namespace mbgl diff --git a/src/mbgl/style/conversion/json.hpp b/src/mbgl/style/conversion/json.hpp index 3a7bf2b557..503f60a382 100644 --- a/src/mbgl/style/conversion/json.hpp +++ b/src/mbgl/style/conversion/json.hpp @@ -4,7 +4,6 @@ #include <mbgl/style/rapidjson_conversion.hpp> #include <string> -#include <sstream> namespace mbgl { namespace style { @@ -16,9 +15,7 @@ optional<T> convertJSON(const std::string& json, Error& error, Args&&...args) { document.Parse<0>(json.c_str()); if (document.HasParseError()) { - std::stringstream message; - message << document.GetErrorOffset() << " - " << rapidjson::GetParseError_En(document.GetParseError()); - error = { message.str() }; + error = { formatJSONParseError(document) }; return {}; } diff --git a/src/mbgl/style/parser.cpp b/src/mbgl/style/parser.cpp index 114a666f08..77cf23bad0 100644 --- a/src/mbgl/style/parser.cpp +++ b/src/mbgl/style/parser.cpp @@ -18,7 +18,6 @@ #include <algorithm> #include <set> -#include <sstream> namespace mbgl { namespace style { @@ -30,11 +29,7 @@ StyleParseResult Parser::parse(const std::string& json) { document.Parse<0>(json.c_str()); if (document.HasParseError()) { - std::stringstream message; - message << document.GetErrorOffset() << " - " - << rapidjson::GetParseError_En(document.GetParseError()); - - return std::make_exception_ptr(std::runtime_error(message.str())); + return std::make_exception_ptr(std::runtime_error(formatJSONParseError(document))); } if (!document.IsObject()) { diff --git a/src/mbgl/text/shaping.cpp b/src/mbgl/text/shaping.cpp index 6d10085ad3..3a6335955b 100644 --- a/src/mbgl/text/shaping.cpp +++ b/src/mbgl/text/shaping.cpp @@ -5,6 +5,7 @@ #include <mbgl/text/bidi.hpp> #include <algorithm> +#include <list> #include <cmath> namespace mbgl { diff --git a/src/mbgl/tile/geometry_tile.cpp b/src/mbgl/tile/geometry_tile.cpp index 9743cd3f7d..80b3e970bd 100644 --- a/src/mbgl/tile/geometry_tile.cpp +++ b/src/mbgl/tile/geometry_tile.cpp @@ -19,8 +19,6 @@ #include <mbgl/util/logging.hpp> #include <mbgl/actor/scheduler.hpp> -#include <iostream> - namespace mbgl { using namespace style; diff --git a/src/mbgl/util/mapbox.cpp b/src/mbgl/util/mapbox.cpp index b823b727a7..6c36c152cd 100644 --- a/src/mbgl/util/mapbox.cpp +++ b/src/mbgl/util/mapbox.cpp @@ -6,7 +6,6 @@ #include <stdexcept> #include <vector> -#include <iostream> #include <cstring> namespace { diff --git a/src/mbgl/util/rapidjson.cpp b/src/mbgl/util/rapidjson.cpp new file mode 100644 index 0000000000..32a3c0b929 --- /dev/null +++ b/src/mbgl/util/rapidjson.cpp @@ -0,0 +1,13 @@ +#include <mbgl/util/rapidjson.hpp> +#include <mbgl/util/string.hpp> + +namespace mbgl { + +std::string formatJSONParseError(const JSDocument& doc) { + return std::string{ rapidjson::GetParseError_En(doc.GetParseError()) } + " at offset " + + util::toString(doc.GetErrorOffset()); +} + +} // namespace mbgl + + diff --git a/src/mbgl/util/rapidjson.hpp b/src/mbgl/util/rapidjson.hpp index 7262e8545c..2fb2a07c9f 100644 --- a/src/mbgl/util/rapidjson.hpp +++ b/src/mbgl/util/rapidjson.hpp @@ -8,4 +8,6 @@ namespace mbgl { using JSDocument = rapidjson::GenericDocument<rapidjson::UTF8<>, rapidjson::CrtAllocator>; using JSValue = rapidjson::GenericValue<rapidjson::UTF8<>, rapidjson::CrtAllocator>; +std::string formatJSONParseError(const JSDocument&); + } // namespace mbgl diff --git a/src/mbgl/util/stopwatch.cpp b/src/mbgl/util/stopwatch.cpp index 3883d8535f..6db9da07e1 100644 --- a/src/mbgl/util/stopwatch.cpp +++ b/src/mbgl/util/stopwatch.cpp @@ -4,7 +4,6 @@ #include <mbgl/util/chrono.hpp> #include <mbgl/util/logging.hpp> -#include <iostream> #include <atomic> namespace mbgl { diff --git a/src/mbgl/util/stopwatch.hpp b/src/mbgl/util/stopwatch.hpp index 0c91342a57..daa313f702 100644 --- a/src/mbgl/util/stopwatch.hpp +++ b/src/mbgl/util/stopwatch.hpp @@ -4,7 +4,10 @@ #include <mbgl/util/chrono.hpp> #include <string> + +#ifdef MBGL_TIMING #include <sstream> +#endif namespace mbgl { namespace util { |