remove boost::format usage

This commit is contained in:
Dane Springmeyer 2014-09-30 18:35:07 -07:00
parent 8bf957e73e
commit 4cbc139689
5 changed files with 29 additions and 25 deletions

View file

@ -28,26 +28,26 @@
#include <mapnik/value_types.hpp>
#include <mapnik/boolean.hpp>
#include <mapnik/util/conversions.hpp>
// boost
#include <boost/optional.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/format.hpp>
// stl
#include <string>
#include <sstream>
#include <stdexcept>
namespace mapnik { namespace detail {
template <typename T>
struct extract_value
{
static inline boost::optional<T> do_extract_from_string(std::string const& /*source*/)
{
std::string err_msg = (boost::format("No conversion from std::string to %s") % typeid(T).name()).str();
throw std::runtime_error(err_msg);
std::ostringstream s;
s << "No conversion from std::string to " << typeid(T).name();
throw std::runtime_error(s.str());
}
};
@ -138,10 +138,10 @@ struct value_extractor_visitor : public util::static_visitor<>
}
catch (boost::bad_lexical_cast const& )
{
std::string err_msg = (boost::format("Failed converting from %s to %s")
% typeid(T1).name()
% typeid(T).name()).str();
throw std::runtime_error(err_msg);
std::ostringstream s;
s << "Failed converting from " << typeid(T1).name()
<< " to " << typeid(T).name();
throw std::runtime_error(s.str());
}
}

View file

@ -30,11 +30,11 @@
#include <mapnik/feature.hpp>
#include <mapnik/feature_factory.hpp>
#include <mapnik/util/variant.hpp>
// boost
#include <boost/format.hpp>
// stl
#include <cmath>
#include <memory>
#include <sstream>
#include "gdal_featureset.hpp"
#include <gdal_priv.h>
@ -210,7 +210,9 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
{
if (band_ > nbands_)
{
throw datasource_exception((boost::format("GDAL Plugin: '%d' is an invalid band, dataset only has '%d' bands\n") % band_ % nbands_).str());
std::ostringstream s;
s << "GDAL Plugin: " << band_ << " is an invalid band, dataset only has " << nbands_ << "bands";
throw datasource_exception(s.str());
}
float* imageData = (float*)image.getBytes();
GDALRasterBand * band = dataset_.GetRasterBand(band_);
@ -484,8 +486,9 @@ void gdal_featureset::get_overview_meta(GDALRasterBand* band)
for (int b = 0; b < band_overviews; b++)
{
GDALRasterBand * overview = band->GetOverview(b);
MAPNIK_LOG_DEBUG(gdal) << boost::format("gdal_featureset: Overview=%d Width=%d Height=%d")
% b % overview->GetXSize() % overview->GetYSize();
MAPNIK_LOG_DEBUG(gdal) << "Overview= " << b
<< " Width=" << overview->GetXSize()
<< " Height=" << overview->GetYSize();
}
}
else
@ -498,8 +501,9 @@ void gdal_featureset::get_overview_meta(GDALRasterBand* band)
band->GetBlockSize(&bsx, &bsy);
scale = band->GetScale();
MAPNIK_LOG_DEBUG(gdal) << boost::format("gdal_featureset: Block=%dx%d Scale=%f Type=%s Color=%s") % bsx % bsy % scale
% GDALGetDataTypeName(band->GetRasterDataType())
% GDALGetColorInterpretationName(band->GetColorInterpretation());
MAPNIK_LOG_DEBUG(gdal) << "Block=" << bsx << "x" << bsy
<< " Scale=" << scale
<< " Type=" << GDALGetDataTypeName(band->GetRasterDataType())
<< "Color=" << GDALGetColorInterpretationName(band->GetColorInterpretation());
}
#endif

View file

@ -142,6 +142,7 @@ std::string tiled_multi_file_policy::interpolate(std::string const& pattern, int
// TODO: make from some sort of configurable interpolation
int tms_y = tile_stride_ * ((image_height_ / tile_size_) - y - 1);
int tms_x = tile_stride_ * x;
// TODO - optimize by avoiding boost::format
std::string xs = (boost::format("%03d/%03d/%03d") % (tms_x / 1000000) % ((tms_x / 1000) % 1000) % (tms_x % 1000)).str();
std::string ys = (boost::format("%03d/%03d/%03d") % (tms_y / 1000000) % ((tms_y / 1000) % 1000) % (tms_y % 1000)).str();
std::string rv(pattern);

View file

@ -26,7 +26,6 @@
// boost
#include <boost/version.hpp>
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
// mapnik
@ -43,6 +42,7 @@
// stl
#include <fstream>
#include <sstream>
#include <stdexcept>
DATASOURCE_PLUGIN(shape_datasource)
@ -166,8 +166,9 @@ void shape_datasource::init(shape_io& shape)
int file_code=shape.shp().read_xdr_integer();
if (file_code!=9994)
{
//invalid file code
throw datasource_exception("Shape Plugin: " + (boost::format("wrong file code : %d") % file_code).str());
std::ostringstream s;
s << "Shape Plugin: wrong file code " << file_code;
throw datasource_exception(s.str());
}
shape.shp().skip(5*4);
@ -176,8 +177,9 @@ void shape_datasource::init(shape_io& shape)
if (version!=1000)
{
//invalid version number
throw datasource_exception("Shape Plugin: " + (boost::format("invalid version number: %d") % version).str());
std::ostringstream s;
s << "Shape Plugin: nvalid version number " << version;
throw datasource_exception(s.str());
}
shape_type_ = static_cast<shape_io::shapeType>(shape.shp().read_ndr_integer());

View file

@ -30,9 +30,6 @@
#include <mapnik/feature.hpp>
#include <mapnik/noncopyable.hpp>
// boost
#include <boost/format.hpp>
namespace mapnik
{