+ use std::unique_ptr instead of std::auto_ptr (deprecated!)

This commit is contained in:
artemp 2013-04-19 09:50:50 +01:00
parent 7cd8c63656
commit c73e48fa58
45 changed files with 167 additions and 121 deletions

View file

@ -12,6 +12,7 @@
#include <sstream>
#include <cstdio>
#include <set>
#include <memory>
// boost
#include <boost/version.hpp>
@ -92,7 +93,7 @@ void benchmark(T & test_runner, std::string const& name)
bool compare_images(std::string const& src_fn,std::string const& dest_fn)
{
std::auto_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
std::unique_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
if (!reader1.get())
{
throw mapnik::image_reader_exception("Failed to load: " + dest_fn);
@ -100,7 +101,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn)
boost::shared_ptr<image_32> image_ptr1 = boost::make_shared<image_32>(reader1->width(),reader1->height());
reader1->read(0,0,image_ptr1->data());
std::auto_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
std::unique_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
if (!reader2.get())
{
throw mapnik::image_reader_exception("Failed to load: " + src_fn);
@ -162,7 +163,7 @@ struct test2
im_()
{
std::string filename("./benchmark/data/multicolor.png");
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename,"png"));
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename,"png"));
if (!reader.get())
{
throw mapnik::image_reader_exception("Failed to load: " + filename);
@ -410,8 +411,8 @@ struct test8
#include <mapnik/rule_cache.hpp>
#if BOOST_VERSION >= 105300
#include <boost/container/vector.hpp>
#include <boost/move/utility.hpp>
//#include <boost/container/vector.hpp>
//#include <boost/move/utility.hpp>
class rule_cache_move
{
@ -593,13 +594,13 @@ struct test10
void operator()()
{
for (unsigned i=0;i<iter_;++i) {
boost::ptr_vector<rule_cache_heap> rule_caches;
std::vector<std::unique_ptr<rule_cache_heap> > rule_caches;
for (unsigned i=0;i<num_styles_;++i) {
std::auto_ptr<rule_cache_heap> rc(new rule_cache_heap);
std::unique_ptr<rule_cache_heap> rc(new rule_cache_heap);
for (unsigned i=0;i<num_rules_;++i) {
rc->add_rule(rules_[i]);
}
rule_caches.push_back(rc);
rule_caches.push_back(std::move(rc));
}
}
}

View file

@ -40,7 +40,7 @@
#if BOOST_VERSION >= 104700
#include <mapnik/util/geometry_to_wkb.hpp>
#include <mapnik/util/geometry_to_wkt.hpp>
#include <mapnik/util/geometry_to_svg.hpp>
//#include <mapnik/util/geometry_to_svg.hpp>
#endif
namespace {
@ -229,7 +229,8 @@ std::string to_geojson( path_type const& geom)
std::string to_svg( geometry_type const& geom)
{
#if BOOST_VERSION >= 104700
#if 0 // BOOST_VERSION >= 104700
std::string svg; // Use Python String directly ?
bool result = mapnik::util::to_svg(svg,geom);
if (!result)
@ -280,7 +281,7 @@ void export_geometry()
#endif
using mapnik::geometry_type;
class_<geometry_type, std::auto_ptr<geometry_type>, boost::noncopyable>("Geometry2d",no_init)
class_<geometry_type, std::shared_ptr<geometry_type>, boost::noncopyable>("Geometry2d",no_init)
.def("envelope",&geometry_type::envelope)
// .def("__str__",&geometry_type::to_string)
.def("type",&geometry_type::type)

View file

@ -151,7 +151,7 @@ boost::shared_ptr<image_32> open_from_file(std::string const& filename)
boost::optional<std::string> type = type_from_filename(filename);
if (type)
{
std::auto_ptr<image_reader> reader(get_image_reader(filename,*type));
std::unique_ptr<image_reader> reader(get_image_reader(filename,*type));
if (reader.get())
{
@ -166,7 +166,7 @@ boost::shared_ptr<image_32> open_from_file(std::string const& filename)
boost::shared_ptr<image_32> fromstring(std::string const& str)
{
std::auto_ptr<image_reader> reader(get_image_reader(str.c_str(),str.size()));
std::unique_ptr<image_reader> reader(get_image_reader(str.c_str(),str.size()));
if (reader.get())
{
boost::shared_ptr<image_32> image_ptr = boost::make_shared<image_32>(reader->width(),reader->height());
@ -182,15 +182,15 @@ boost::shared_ptr<image_32> frombuffer(PyObject * obj)
Py_ssize_t buffer_len;
if (PyObject_AsReadBuffer(obj, &buffer, &buffer_len) == 0)
{
std::auto_ptr<image_reader> reader(get_image_reader(reinterpret_cast<char const*>(buffer),buffer_len));
std::unique_ptr<image_reader> reader(get_image_reader(reinterpret_cast<char const*>(buffer),buffer_len));
if (reader.get())
{
boost::shared_ptr<image_32> image_ptr = boost::make_shared<image_32>(reader->width(),reader->height());
reader->read(0,0,image_ptr->data());
return image_ptr;
}
throw mapnik::image_reader_exception("Failed to load image from buffer" );
}
throw mapnik::image_reader_exception("Failed to load image from buffer" );
}

View file

@ -23,6 +23,8 @@
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_HPP
#define MAPNIK_CSS_COLOR_GRAMMAR_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik
#include <mapnik/color.hpp>

View file

@ -23,6 +23,8 @@
#ifndef MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP
#define MAPNIK_CSS_COLOR_GRAMMAR_DEF_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// boost
#include <boost/version.hpp>

View file

@ -23,6 +23,8 @@
#ifndef MAPNIK_EXPRESSIONS_GRAMMAR_HPP
#define MAPNIK_EXPRESSIONS_GRAMMAR_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik
#include <mapnik/value_types.hpp>
#include <mapnik/unicode.hpp>

View file

@ -54,7 +54,7 @@
// stl
#include <vector>
#include <memory>
#if defined(RENDERING_STATS)
#include <mapnik/timer.hpp>
@ -400,7 +400,9 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
attribute_collector collector(names);
double filt_factor = 1.0;
directive_collector d_collector(filt_factor);
boost::ptr_vector<rule_cache> rule_caches;
std::vector<std::unique_ptr<rule_cache> > rule_caches;
//boost::ptr_vector<rule_cache> rule_caches;
// iterate through all named styles collecting active styles and attribute names
BOOST_FOREACH(std::string const& style_name, style_names)
@ -417,12 +419,12 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
std::vector<rule> const& rules = style->get_rules();
bool active_rules = false;
std::auto_ptr<rule_cache> rc(new rule_cache);
BOOST_FOREACH(rule const& r, rules)
std::unique_ptr<rule_cache> rc_ptr(new rule_cache);
for (auto const& r : rules)
{
if (r.active(scale_denom))
{
rc->add_rule(r);
rc_ptr->add_rule(r);
active_rules = true;
if (ds->type() == datasource::Vector)
{
@ -433,7 +435,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
}
if (active_rules)
{
rule_caches.push_back(rc);
rule_caches.push_back(std::move(rc_ptr));
active_styles.push_back(&(*style));
}
}
@ -505,7 +507,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
int i = 0;
BOOST_FOREACH (feature_type_style const* style, active_styles)
{
render_style(lay, p, style, rule_caches[i], style_names[i],
render_style(lay, p, style, *rule_caches[i], style_names[i],
cache.features(q), prj_trans);
i++;
}
@ -518,7 +520,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
int i = 0;
BOOST_FOREACH (feature_type_style const* style, active_styles)
{
render_style(lay, p, style, rule_caches[i], style_names[i],
render_style(lay, p, style, *rule_caches[i], style_names[i],
cache.features(q), prj_trans);
i++;
}
@ -539,7 +541,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
int i = 0;
BOOST_FOREACH (feature_type_style const* style, active_styles)
{
render_style(lay, p, style, rule_caches[i], style_names[i],
render_style(lay, p, style, *rule_caches[i], style_names[i],
cache.features(q), prj_trans);
i++;
}
@ -550,7 +552,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
int i = 0;
BOOST_FOREACH (feature_type_style const* style, active_styles)
{
render_style(lay, p, style, rule_caches[i], style_names[i],
render_style(lay, p, style, *rule_caches[i], style_names[i],
ds->features(q), prj_trans);
i++;
}

View file

@ -23,6 +23,7 @@
#ifndef MAPNIK_IMAGE_FILITER_GRAMMAR_HPP
#define MAPNIK_IMAGE_FILITER_GRAMMAR_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// boost
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/include/adapt_struct.hpp>

View file

@ -28,6 +28,7 @@
#include <mapnik/json/feature_grammar.hpp>
#include <mapnik/feature.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// spirit::qi
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
@ -42,14 +43,14 @@ using standard_wide::space_type;
struct generate_id
{
typedef int result_type;
generate_id(int start)
: id_(start) {}
int operator() () const
{
return id_++;
}
}
mutable int id_;
};
@ -76,7 +77,7 @@ struct feature_collection_grammar :
feature_collection = lit('{') >> (type | features) % lit(",") >> lit('}')
;
type = lit("\"type\"") > lit(":") > lit("\"FeatureCollection\"")
;
@ -86,29 +87,29 @@ struct feature_collection_grammar :
> -(feature(_val) % lit(','))
> lit(']')
;
feature = eps[_a = phoenix::construct<mapnik::feature_ptr>(new_<mapnik::feature_impl>(ctx_,generate_id_()))]
>> feature_g(*_a)[push_back(_r1,_a)]
;
type.name("type");
features.name("features");
feature.name("feature");
feature_g.name("feature-grammar");
qi::on_error<qi::fail>
(
feature_collection
, std::clog
<< phoenix::val("Error parsing GeoJSON ")
<< qi::_4
<< qi::_4
<< phoenix::val(" here: \"")
<< construct<std::string>(qi::_3, qi::_2)
<< construct<std::string>(qi::_3, qi::_2)
<< phoenix::val("\"")
<< std::endl
);
}
context_ptr ctx_;
qi::rule<Iterator, std::vector<feature_ptr>(), space_type> feature_collection; // START
qi::rule<Iterator, space_type> type;

View file

@ -23,6 +23,8 @@
#ifndef MAPNIK_JSON_FEATURE_GENERATOR_GRAMMAR_HPP
#define MAPNIK_JSON_FEATURE_GENERATOR_GRAMMAR_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/value.hpp>

View file

@ -30,6 +30,7 @@
#include <mapnik/unicode.hpp>
#include <mapnik/value.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// spirit::qi
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/apply_visitor.hpp>

View file

@ -23,6 +23,7 @@
#ifndef MAPNIK_JSON_GEOMETRY_GENERATOR_GRAMMAR_HPP
#define MAPNIK_JSON_GEOMETRY_GENERATOR_GRAMMAR_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
@ -42,8 +43,6 @@
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
//#define BOOST_SPIRIT_USE_PHOENIX_V3 1
namespace boost { namespace spirit { namespace traits {
// make gcc and darwin toolsets happy.

View file

@ -27,6 +27,8 @@
#include <mapnik/geometry.hpp> // for geometry_type
#include <mapnik/vertex.hpp> // for CommandType
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// spirit::qi
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_function.hpp>

View file

@ -26,6 +26,7 @@
// mapnik
#include <mapnik/path_expression.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// spirit2
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_action.hpp>

View file

@ -103,14 +103,14 @@ private:
// otherwise it will autodetect the orientation.
// If >= 50% of the characters end up upside down, it will be retried the other way.
// RETURN: 1/-1 depending which way up the string ends up being.
std::auto_ptr<text_path> get_placement_offset(std::vector<vertex2d> const& path_positions,
std::unique_ptr<text_path> get_placement_offset(std::vector<vertex2d> const& path_positions,
std::vector<double> const& path_distances,
int & orientation, unsigned index, double distance);
///Tests whether the given text_path be placed without a collision
// Returns true if it can
// NOTE: This edits p.envelopes so it can be used afterwards (you must clear it otherwise)
bool test_placement(std::auto_ptr<text_path> const& current_placement, int orientation);
bool test_placement(std::unique_ptr<text_path> const& current_placement, int orientation);
///Does a line-circle intersect calculation
// NOTE: Follow the strict pre conditions

View file

@ -41,9 +41,9 @@ class rule_cache
public:
typedef std::vector<rule const*> rule_ptrs;
rule_cache()
: if_rules_(),
else_rules_(),
also_rules_() {}
: if_rules_(),
else_rules_(),
also_rules_() {}
void add_rule(rule const& r)
{
@ -65,12 +65,12 @@ public:
{
return if_rules_;
}
rule_ptrs const& get_else_rules() const
{
return else_rules_;
}
rule_ptrs const& get_also_rules() const
{
return also_rules_;

View file

@ -26,6 +26,7 @@
// mapnik
#include <mapnik/svg/svg_path_commands.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// spirit
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_function.hpp>

View file

@ -27,6 +27,7 @@
#include <mapnik/expression_grammar.hpp>
#include <mapnik/transform_expression.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// spirit
#include <boost/spirit/include/qi.hpp>

View file

@ -23,6 +23,8 @@
#ifndef MAPNIK_UTIL_DASHARRAY_PARSER_HPP
#define MAPNIK_UTIL_DASHARRAY_PARSER_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
@ -44,10 +46,10 @@ bool parse_dasharray(Iterator first, Iterator last, std::vector<double>& dasharr
using qi::lexeme;
#endif
using phoenix::push_back;
// SVG
// SVG
// dasharray ::= (length | percentage) (comma-wsp dasharray)?
// no support for 'percentage' as viewport is unknown at load_map
//
//
bool r = phrase_parse(first, last,
(double_[push_back(phoenix::ref(dasharray), _1)] %
#if BOOST_VERSION > 104200
@ -57,10 +59,10 @@ bool parse_dasharray(Iterator first, Iterator last, std::vector<double>& dasharr
#endif
| lit("none")),
qi::ascii::space);
if (first != last)
if (first != last)
return false;
return r;
}

View file

@ -23,6 +23,8 @@
#ifndef MAPNIK_GEOMETRY_SVG_GENERATOR_HPP
#define MAPNIK_GEOMETRY_SVG_GENERATOR_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp> // for container stuff
@ -41,7 +43,6 @@
#include <boost/fusion/include/boost_tuple.hpp>
#include <boost/type_traits/remove_pointer.hpp>
//#define BOOST_SPIRIT_USE_PHOENIX_V3 1
/*!
* adapted to conform to the concepts

View file

@ -28,6 +28,8 @@
#include <mapnik/geometry.hpp>
#include <mapnik/util/geometry_svg_generator.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// boost
#include <boost/spirit/include/karma.hpp>

View file

@ -23,11 +23,15 @@
#ifndef MAPNIK_GEOMETRY_WKT_GENERATOR_HPP
#define MAPNIK_GEOMETRY_WKT_GENERATOR_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik
#include <mapnik/global.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/vertex.hpp> // for CommandType::SEG_MOVETO
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// boost
#include <boost/tuple/tuple.hpp>
#include <boost/spirit/include/karma.hpp>
@ -40,7 +44,7 @@
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/math/special_functions/trunc.hpp> // trunc to avoid needing C++11
//#define BOOST_SPIRIT_USE_PHOENIX_V3 1
namespace boost { namespace spirit { namespace traits {

View file

@ -23,6 +23,8 @@
#ifndef MAPNIK_WKT_GRAMMAR_HPP
#define MAPNIK_WKT_GRAMMAR_HPP
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
#include <boost/assert.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
// spirit::qi

View file

@ -79,21 +79,21 @@ void ogr_converter::convert_geometry(OGRGeometry* geom, feature_ptr feature)
void ogr_converter::convert_point(OGRPoint* geom, feature_ptr feature)
{
std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
std::unique_ptr<geometry_type> point(new geometry_type(mapnik::Point));
point->move_to(geom->getX(), geom->getY());
feature->paths().push_back(point);
feature->paths().push_back(point.release());
}
void ogr_converter::convert_linestring(OGRLineString* geom, feature_ptr feature)
{
int num_points = geom->getNumPoints();
std::auto_ptr<geometry_type> line(new geometry_type(mapnik::LineString));
std::unique_ptr<geometry_type> line(new geometry_type(mapnik::LineString));
line->move_to(geom->getX(0), geom->getY(0));
for (int i = 1; i < num_points; ++i)
{
line->line_to (geom->getX(i), geom->getY(i));
}
feature->paths().push_back(line);
feature->paths().push_back(line.release());
}
void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
@ -108,7 +108,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
capacity += interior->getNumPoints();
}
std::auto_ptr<geometry_type> poly(new geometry_type(mapnik::Polygon));
std::unique_ptr<geometry_type> poly(new geometry_type(mapnik::Polygon));
poly->move_to(exterior->getX(0), exterior->getY(0));
for (int i = 1; i < num_points; ++i)
@ -127,7 +127,7 @@ void ogr_converter::convert_polygon(OGRPolygon* geom, feature_ptr feature)
}
poly->close_path();
}
feature->paths().push_back(poly);
feature->paths().push_back(poly.release());
}
void ogr_converter::convert_multipoint(OGRMultiPoint* geom, feature_ptr feature)

View file

@ -118,7 +118,7 @@ raster_datasource::raster_datasource(parameters const& params)
try
{
std::auto_ptr<image_reader> reader(mapnik::get_image_reader(filename_, format_));
std::unique_ptr<image_reader> reader(mapnik::get_image_reader(filename_, format_));
if (reader.get())
{
width_ = reader->width();

View file

@ -70,7 +70,7 @@ feature_ptr raster_featureset<LookupPolicy>::next()
try
{
std::auto_ptr<image_reader> reader(mapnik::get_image_reader(curIter_->file(),curIter_->format()));
std::unique_ptr<image_reader> reader(mapnik::get_image_reader(curIter_->file(),curIter_->format()));
MAPNIK_LOG_DEBUG(raster) << "raster_featureset: Reader=" << curIter_->format() << "," << curIter_->file()
<< ",size(" << curIter_->width() << "," << curIter_->height() << ")";

View file

@ -89,9 +89,9 @@ feature_ptr shape_featureset<filterT>::next()
double y = record.read_double();
if (!filter_.pass(mapnik::box2d<double>(x,y,x,y)))
continue;
std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
std::unique_ptr<geometry_type> point(new geometry_type(mapnik::Point));
point->move_to(x, y);
feature->paths().push_back(point);
feature->paths().push_back(point.release());
break;
}
case shape_io::shape_multipoint:
@ -105,9 +105,9 @@ feature_ptr shape_featureset<filterT>::next()
{
double x = record.read_double();
double y = record.read_double();
std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
std::unique_ptr<geometry_type> point(new geometry_type(mapnik::Point));
point->move_to(x, y);
feature->paths().push_back(point);
feature->paths().push_back(point.release());
}
break;
}

View file

@ -99,9 +99,9 @@ feature_ptr shape_index_featureset<filterT>::next()
{
double x = record.read_double();
double y = record.read_double();
std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
std::unique_ptr<geometry_type> point(new geometry_type(mapnik::Point));
point->move_to(x, y);
feature->paths().push_back(point);
feature->paths().push_back(point.release());
break;
}
case shape_io::shape_multipoint:
@ -115,9 +115,9 @@ feature_ptr shape_index_featureset<filterT>::next()
{
double x = record.read_double();
double y = record.read_double();
std::auto_ptr<geometry_type> point(new geometry_type(mapnik::Point));
std::unique_ptr<geometry_type> point(new geometry_type(mapnik::Point));
point->move_to(x, y);
feature->paths().push_back(point);
feature->paths().push_back(point.release());
}
break;
}

View file

@ -97,7 +97,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry
int num_points = record.read_ndr_integer();
if (num_parts == 1)
{
std::auto_ptr<geometry_type> line(new geometry_type(mapnik::LineString));
std::unique_ptr<geometry_type> line(new geometry_type(mapnik::LineString));
record.skip(4);
double x = record.read_double();
double y = record.read_double();
@ -108,7 +108,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry
y = record.read_double();
line->line_to(x, y);
}
geom.push_back(line);
geom.push_back(line.release());
}
else
{
@ -121,7 +121,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry
int start, end;
for (int k = 0; k < num_parts; ++k)
{
std::auto_ptr<geometry_type> line(new geometry_type(mapnik::LineString));
std::unique_ptr<geometry_type> line(new geometry_type(mapnik::LineString));
start = parts[k];
if (k == num_parts - 1)
{
@ -142,7 +142,7 @@ void shape_io::read_polyline( shape_file::record_type & record, mapnik::geometry
y = record.read_double();
line->line_to(x, y);
}
geom.push_back(line);
geom.push_back(line.release());
}
}
}
@ -160,7 +160,7 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c
for (int k = 0; k < num_parts; ++k)
{
std::auto_ptr<geometry_type> poly(new geometry_type(mapnik::Polygon));
std::unique_ptr<geometry_type> poly(new geometry_type(mapnik::Polygon));
int start = parts[k];
int end;
if (k == num_parts - 1)
@ -182,6 +182,6 @@ void shape_io::read_polygon(shape_file::record_type & record, mapnik::geometry_c
poly->line_to(x, y);
}
poly->close_path();
geom.push_back(poly);
geom.push_back(poly.release());
}
}

View file

@ -26,6 +26,8 @@
#include <cstring>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
#include <boost/spirit/include/qi.hpp>
#if _MSC_VER

View file

@ -20,6 +20,8 @@
*
*****************************************************************************/
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik
#include <mapnik/expression_grammar.hpp>
#include <mapnik/expression_node.hpp>
@ -142,7 +144,7 @@ expression_grammar<Iterator>::expression_grammar(mapnik::transcoder const& tr)
multiplicative_expr = unary_expr [_val = _1]
>> *( '*' >> unary_expr [_val *= _1]
| '/' >> unary_expr [_val /= _1]
| '%' >> unary_expr [_val %= _1]
// | '%' >> unary_expr [_val %= _1] --> FIXME
| regex_match_expr[_val = regex_match_(_val, _1)]
| regex_replace_expr(_val) [_val = _1]
)

View file

@ -22,9 +22,8 @@
// TODO https://github.com/mapnik/mapnik/issues/1658
#include <boost/version.hpp>
#if BOOST_VERSION >= 105200
#define BOOST_SPIRIT_USE_PHOENIX_V3
#endif
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik
#include <mapnik/json/feature_collection_parser.hpp>
@ -65,4 +64,3 @@ namespace mapnik { namespace json {
template class feature_collection_parser<boost::spirit::multi_pass<std::istreambuf_iterator<char> > >;
}}

View file

@ -27,6 +27,7 @@
#include <mapnik/feature.hpp>
#include <mapnik/json/feature_grammar.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// boost
#include <boost/spirit/include/support_multi_pass.hpp>

View file

@ -25,6 +25,8 @@
#include <mapnik/feature.hpp>
#include <mapnik/json/geojson_generator.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
#if BOOST_VERSION >= 104700
#include <mapnik/json/feature_generator_grammar.hpp>
@ -34,26 +36,28 @@
namespace mapnik { namespace json {
feature_generator::feature_generator()
: grammar_(new feature_generator_grammar<sink_type>()) {}
: grammar_(0) {} // new feature_generator_grammar<sink_type>()) {}
feature_generator::~feature_generator() {}
bool feature_generator::generate(std::string & geojson, mapnik::feature_impl const& f)
{
sink_type sink(geojson);
return karma::generate(sink, *grammar_,f);
//sink_type sink(geojson);
//return karma::generate(sink, *grammar_,f);
return false;
}
geometry_generator::geometry_generator()
: grammar_(new multi_geometry_generator_grammar<sink_type>()) {}
: grammar_(0) {} //new multi_geometry_generator_grammar<sink_type>()) {}
geometry_generator::~geometry_generator() {}
bool geometry_generator::generate(std::string & geojson, mapnik::geometry_container const& g)
{
sink_type sink(geojson);
return karma::generate(sink, *grammar_,g);
//sink_type sink(geojson);
// return karma::generate(sink, *grammar_,g);
return false;
}
}}

View file

@ -26,6 +26,8 @@
// mapnik
#include <mapnik/json/geometry_grammar.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// boost
#include <boost/spirit/include/support_multi_pass.hpp>
#include <boost/spirit/include/phoenix_object.hpp>

View file

@ -21,6 +21,8 @@
*****************************************************************************/
// mapnik
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
#include <mapnik/json/geometry_parser.hpp>
#include <mapnik/json/geometry_grammar.hpp>

View file

@ -192,7 +192,7 @@ boost::optional<marker_ptr> marker_cache::find(std::string const& uri,
else
{
// TODO - support reading images from string
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(uri));
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(uri));
if (reader.get())
{
unsigned width = reader->width();

View file

@ -387,7 +387,7 @@ void placement_finder<DetectorT>::find_point_placement(double label_x,
double sina = std::sin(rad);
double x, y;
std::auto_ptr<text_path> current_placement(new text_path(label_x, label_y));
std::unique_ptr<text_path> current_placement(new text_path(label_x, label_y));
adjust_position(current_placement.get());
@ -640,10 +640,10 @@ void placement_finder<DetectorT>::find_line_placements(PathT & shape_path)
{
//Record details for the start of the string placement
int orientation = 0;
std::auto_ptr<text_path> current_placement = get_placement_offset(path_positions, path_distances, orientation, index, segment_length - (distance - target_distance) + (diff*dir));
std::unique_ptr<text_path> current_placement = get_placement_offset(path_positions, path_distances, orientation, index, segment_length - (distance - target_distance) + (diff*dir));
//We were unable to place here
if (current_placement.get() == NULL)
if (current_placement.get() == nullptr)
continue;
//Apply displacement
@ -710,7 +710,7 @@ void placement_finder<DetectorT>::find_line_placements(PathT & shape_path)
}
template <typename DetectorT>
std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::vector<vertex2d> const& path_positions,
std::unique_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::vector<vertex2d> const& path_positions,
std::vector<double> const& path_distances,
int & orientation,
unsigned index,
@ -723,7 +723,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
distance += path_distances[index];
}
if (index <= 1 && distance < 0) //We've gone off the start, fail out
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
//Same thing, checking if we go off the end
while (index < path_distances.size() && distance > path_distances[index])
@ -732,7 +732,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
index++;
}
if (index >= path_distances.size())
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
//Keep track of the initial index,distance incase we need to re-call get_placement_offset
const unsigned initial_index = index;
@ -750,10 +750,10 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
double segment_length = path_distances[index];
if (segment_length == 0) {
// Not allowed to place across on 0 length segments or discontinuities
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
}
std::auto_ptr<text_path> current_placement(
std::unique_ptr<text_path> current_placement(
new text_path((old_x + dx*distance/segment_length),
(old_y + dy*distance/segment_length)
)
@ -778,7 +778,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
//Coordinates this character will start at
if (segment_length == 0) {
// Not allowed to place across on 0 length segments or discontinuities
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
}
double start_x = old_x + dx*distance/segment_length;
double start_y = old_y + dy*distance/segment_length;
@ -806,7 +806,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
if (index >= path_positions.size()) //Bail out if we run off the end of the shape
{
//MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Out of space";
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
}
new_x = path_positions[index].x;
new_y = path_positions[index].y;
@ -843,7 +843,7 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
std::fabs(angle_delta) > p.max_char_angle_delta)
{
//MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Too Bendy!";
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
}
double render_angle = angle;
@ -897,15 +897,15 @@ std::auto_ptr<text_path> placement_finder<DetectorT>::get_placement_offset(std::
{
//Otherwise we have failed to find a placement
//MAPNIK_LOG_ERROR(placement_finder) << "FAIL: Double upside-down!";
return std::auto_ptr<text_path>(NULL);
return std::unique_ptr<text_path>(nullptr);
}
}
return current_placement;
return std::move(current_placement);
}
template <typename DetectorT>
bool placement_finder<DetectorT>::test_placement(std::auto_ptr<text_path> const& current_placement,
bool placement_finder<DetectorT>::test_placement(std::unique_ptr<text_path> const& current_placement,
int orientation)
{
//Create and test envelopes

View file

@ -26,6 +26,8 @@
#include <mapnik/ptree_helpers.hpp>
#include <mapnik/xml_node.hpp>
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// boost
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>

View file

@ -20,6 +20,7 @@
*
*****************************************************************************/
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
// mapnik
#include <mapnik/transform_expression_grammar.hpp>

View file

@ -250,9 +250,9 @@ private:
{
double x = read_double();
double y = read_double();
std::auto_ptr<geometry_type> pt(new geometry_type(Point));
std::unique_ptr<geometry_type> pt(new geometry_type(Point));
pt->move_to(x, y);
paths.push_back(pt);
paths.push_back(pt.release());
}
void read_multipoint(boost::ptr_vector<geometry_type> & paths)
@ -269,10 +269,10 @@ private:
{
double x = read_double();
double y = read_double();
std::auto_ptr<geometry_type> pt(new geometry_type(Point));
std::unique_ptr<geometry_type> pt(new geometry_type(Point));
pos_ += 8; // double z = read_double();
pt->move_to(x, y);
paths.push_back(pt);
paths.push_back(pt.release());
}
void read_multipoint_xyz(boost::ptr_vector<geometry_type> & paths)
@ -292,13 +292,13 @@ private:
{
CoordinateArray ar(num_points);
read_coords(ar);
std::auto_ptr<geometry_type> line(new geometry_type(LineString));
std::unique_ptr<geometry_type> line(new geometry_type(LineString));
line->move_to(ar[0].x, ar[0].y);
for (int i = 1; i < num_points; ++i)
{
line->line_to(ar[i].x, ar[i].y);
}
paths.push_back(line);
paths.push_back(line.release());
}
}
@ -319,13 +319,13 @@ private:
{
CoordinateArray ar(num_points);
read_coords_xyz(ar);
std::auto_ptr<geometry_type> line(new geometry_type(LineString));
std::unique_ptr<geometry_type> line(new geometry_type(LineString));
line->move_to(ar[0].x, ar[0].y);
for (int i = 1; i < num_points; ++i)
{
line->line_to(ar[i].x, ar[i].y);
}
paths.push_back(line);
paths.push_back(line.release());
}
}
@ -345,7 +345,7 @@ private:
int num_rings = read_integer();
if (num_rings > 0)
{
std::auto_ptr<geometry_type> poly(new geometry_type(Polygon));
std::unique_ptr<geometry_type> poly(new geometry_type(Polygon));
for (int i = 0; i < num_rings; ++i)
{
int num_points = read_integer();
@ -362,7 +362,7 @@ private:
}
}
if (poly->size() > 3) // ignore if polygon has less than (3 + close_path) vertices
paths.push_back(poly);
paths.push_back(poly.release());
}
}
@ -381,7 +381,7 @@ private:
int num_rings = read_integer();
if (num_rings > 0)
{
std::auto_ptr<geometry_type> poly(new geometry_type(Polygon));
std::unique_ptr<geometry_type> poly(new geometry_type(Polygon));
for (int i = 0; i < num_rings; ++i)
{
int num_points = read_integer();
@ -398,7 +398,7 @@ private:
}
}
if (poly->size() > 2) // ignore if polygon has less than 3 vertices
paths.push_back(poly);
paths.push_back(poly.release());
}
}

View file

@ -1,3 +1,5 @@
#define BOOST_SPIRIT_USE_PHOENIX_V3 1
#include <boost/version.hpp>
#include <mapnik/value_types.hpp>
#include <mapnik/util/conversions.hpp>

View file

@ -12,7 +12,7 @@
#if BOOST_VERSION >= 104700
#include <mapnik/util/geometry_to_wkb.hpp>
#include <mapnik/util/geometry_to_wkt.hpp>
#include <mapnik/util/geometry_to_svg.hpp>
//#include <mapnik/util/geometry_to_svg.hpp>
#endif
#include <boost/detail/lightweight_test.hpp>
@ -29,14 +29,14 @@ struct output_geometry_backend
{
mapnik::vertex2d vtx(mapnik::vertex2d::no_init);
path.rewind(0);
std::auto_ptr<mapnik::geometry_type> geom_ptr(new mapnik::geometry_type(type_));
std::unique_ptr<mapnik::geometry_type> geom_ptr(new mapnik::geometry_type(type_));
while ((vtx.cmd = path.vertex(&vtx.x, &vtx.y)) != mapnik::SEG_END)
{
//std::cerr << vtx.x << "," << vtx.y << " cmd=" << vtx.cmd << std::endl;
geom_ptr->push_vertex(vtx.x, vtx.y, (mapnik::CommandType)vtx.cmd);
}
paths_.push_back(geom_ptr);
paths_.push_back(geom_ptr.release());
}
boost::ptr_vector<mapnik::geometry_type> & paths_;
mapnik::eGeomType type_;

View file

@ -22,7 +22,7 @@ int main( int, char*[] )
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
@ -36,7 +36,7 @@ int main( int, char*[] )
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
@ -50,7 +50,7 @@ int main( int, char*[] )
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
@ -64,7 +64,7 @@ int main( int, char*[] )
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
BOOST_TEST( false );
}
catch (std::exception const&)
@ -78,7 +78,7 @@ int main( int, char*[] )
BOOST_TEST( type );
try
{
std::auto_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(should_throw,*type));
BOOST_TEST( false );
}
catch (std::exception const&)

View file

@ -22,7 +22,7 @@
bool compare_images(std::string const& src_fn,std::string const& dest_fn)
{
using namespace mapnik;
std::auto_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
std::unique_ptr<mapnik::image_reader> reader1(mapnik::get_image_reader(dest_fn,"png"));
if (!reader1.get())
{
throw mapnik::image_reader_exception("Failed to load: " + dest_fn);
@ -30,7 +30,7 @@ bool compare_images(std::string const& src_fn,std::string const& dest_fn)
boost::shared_ptr<image_32> image_ptr1 = boost::make_shared<image_32>(reader1->width(),reader1->height());
reader1->read(0,0,image_ptr1->data());
std::auto_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
std::unique_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(src_fn,"png"));
if (!reader2.get())
{
throw mapnik::image_reader_exception("Failed to load: " + src_fn);