[core] remove some uses of <iostream> and <sstream>
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#include <vector>
|
||||
#include <bitset>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <mbgl/util/platform.hpp>
|
||||
#include <mbgl/util/hash.hpp>
|
||||
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {};
|
||||
}
|
||||
|
||||
|
||||
@@ -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()) {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <mbgl/text/bidi.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <list>
|
||||
#include <cmath>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -19,8 +19,6 @@
|
||||
#include <mbgl/util/logging.hpp>
|
||||
#include <mbgl/actor/scheduler.hpp>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
using namespace style;
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <stdexcept>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
namespace {
|
||||
|
||||
13
src/mbgl/util/rapidjson.cpp
Normal file
13
src/mbgl/util/rapidjson.cpp
Normal file
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
#include <mbgl/util/logging.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <atomic>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -4,7 +4,10 @@
|
||||
#include <mbgl/util/chrono.hpp>
|
||||
|
||||
#include <string>
|
||||
|
||||
#ifdef MBGL_TIMING
|
||||
#include <sstream>
|
||||
#endif
|
||||
|
||||
namespace mbgl {
|
||||
namespace util {
|
||||
|
||||
Reference in New Issue
Block a user