c++11 : use nullptr instead of NULL

This commit is contained in:
artemp 2013-11-27 15:52:47 +00:00
parent 3e69c337d2
commit eb3da7d32d
29 changed files with 79 additions and 81 deletions

View file

@ -159,7 +159,7 @@ void register_cairo()
#else
Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import(const_cast<char *>("cairo"), const_cast<char *>("CAPI"));
#endif
if (Pycairo_CAPI == NULL) return;
if (Pycairo_CAPI == nullptr) return;
boost::python::converter::registry::insert(&extract_surface, boost::python::type_id<PycairoSurface>());
boost::python::converter::registry::insert(&extract_context, boost::python::type_id<PycairoContext>());
@ -503,7 +503,7 @@ bool has_pycairo()
#else
Pycairo_CAPI = (Pycairo_CAPI_t*) PyCObject_Import(const_cast<char *>("cairo"), const_cast<char *>("CAPI"));
#endif
if (Pycairo_CAPI == NULL){
if (Pycairo_CAPI == nullptr){
/*
Case where pycairo support has been compiled into
mapnik but at runtime the cairo python module

View file

@ -196,7 +196,7 @@ namespace mapnik {
#ifdef MAPNIK_LOG
base_log(const char* object_name)
{
if (object_name != NULL)
if (object_name != nullptr)
{
object_name_ = object_name;
}
@ -265,7 +265,7 @@ namespace mapnik {
base_log_always(const char* object_name)
{
if (object_name != NULL)
if (object_name != nullptr)
{
object_name_ = object_name;
}

View file

@ -389,7 +389,7 @@ public:
* @param index The index of the layer to query from.
* @param x The x coordinate where to query.
* @param y The y coordinate where to query.
* @return A Mapnik Featureset if successful otherwise will return NULL.
* @return A Mapnik Featureset if successful otherwise will return nullptr.
*/
featureset_ptr query_point(unsigned index, double x, double y) const;
@ -402,7 +402,7 @@ public:
* @param index The index of the layer to query from.
* @param x The x coordinate where to query.
* @param y The y coordinate where to query.
* @return A Mapnik Featureset if successful otherwise will return NULL.
* @return A Mapnik Featureset if successful otherwise will return nullptr.
*/
featureset_ptr query_map_point(unsigned index, double x, double y) const;

View file

@ -146,7 +146,7 @@ void save_as_png(T1 & file,
row_pointers[i] = (png_bytep)image.getRow(i);
}
png_set_rows(png_ptr, info_ptr, row_pointers.get());
png_write_png(png_ptr, info_ptr, (opts.trans_mode == 0) ? PNG_TRANSFORM_STRIP_FILLER_AFTER : PNG_TRANSFORM_IDENTITY, NULL);
png_write_png(png_ptr, info_ptr, (opts.trans_mode == 0) ? PNG_TRANSFORM_STRIP_FILLER_AFTER : PNG_TRANSFORM_IDENTITY, nullptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
}

View file

@ -32,12 +32,12 @@ struct weighted_vertex : private mapnik::noncopyable
weighted_vertex(vertex2d coord_) :
coord(coord_),
weight(std::numeric_limits<double>::infinity()),
prev(NULL),
next(NULL) {}
prev(nullptr),
next(nullptr) {}
double nominalWeight()
{
if (prev == NULL || next == NULL || coord.cmd != SEG_LINETO) {
if (prev == nullptr || next == nullptr || coord.cmd != SEG_LINETO) {
return std::numeric_limits<double>::infinity();
}
vertex2d const& A = prev->coord;
@ -392,8 +392,8 @@ private:
VertexSet v;
for (VertexList::iterator i = v_list.begin(); i != v_list.end(); ++i)
{
(*i)->prev = i == v_list.begin() ? NULL : *(i - 1);
(*i)->next = i + 1 == v_list.end() ? NULL : *(i + 1);
(*i)->prev = i == v_list.begin() ? nullptr : *(i - 1);
(*i)->next = i + 1 == v_list.end() ? nullptr : *(i + 1);
(*i)->weight = (*i)->nominalWeight();
v.insert(*i);
}

View file

@ -62,7 +62,7 @@ occi_featureset::occi_featureset(StatelessConnectionPool* pool,
bool use_connection_pool,
bool use_wkb,
unsigned prefetch_rows)
: rs_(NULL),
: rs_(nullptr),
tr_(new transcoder(encoding)),
feature_id_(1),
ctx_(ctx),
@ -85,7 +85,7 @@ occi_featureset::occi_featureset(StatelessConnectionPool* pool,
{
MAPNIK_LOG_ERROR(occi) << "OCCI Plugin: error processing " << sqlstring << " : " << ex.getMessage();
rs_ = NULL;
rs_ = nullptr;
}
}
@ -95,7 +95,7 @@ occi_featureset::~occi_featureset()
feature_ptr occi_featureset::next()
{
while (rs_ != NULL && rs_->next() == oracle::occi::ResultSet::DATA_AVAILABLE)
while (rs_ != nullptr && rs_->next() == oracle::occi::ResultSet::DATA_AVAILABLE)
{
feature_ptr feature(feature_factory::create(ctx_, feature_id_));

View file

@ -97,7 +97,7 @@ void *SDOPointType::readSQL(void *ctxOCCI_)
{
delete objOCCI_;
excep.setErrorCtx(ctxOCCI_);
return (void *)NULL;
return (void *)nullptr;
}
return (void *)objOCCI_;
}
@ -264,7 +264,7 @@ void *SDOGeometry::readSQL(void *ctxOCCI_)
{
delete objOCCI_;
excep.setErrorCtx(ctxOCCI_);
return (void *)NULL;
return (void *)nullptr;
}
return (void *)objOCCI_;
}

View file

@ -163,7 +163,7 @@ void ogr_converter::convert_collection(OGRGeometryCollection* geom, feature_ptr
for (int i = 0; i < num_geometries; ++i)
{
OGRGeometry* g = geom->getGeometryRef(i);
if (g != NULL)
if (g != nullptr)
{
convert_geometry(g, feature);
}

View file

@ -112,7 +112,7 @@ void ogr_datasource::init(mapnik::parameters const& params)
if (! driver.empty())
{
OGRSFDriver * ogr_driver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(driver.c_str());
if (ogr_driver && ogr_driver != NULL)
if (ogr_driver && ogr_driver != nullptr)
{
dataset_ = ogr_driver->Open((dataset_name_).c_str(), FALSE);
}
@ -382,7 +382,7 @@ boost::optional<mapnik::datasource::geometry_t> ogr_datasource::get_geometry_typ
//layer->ResetReading();
layer->SetNextByIndex(0);
OGRFeature *poFeature;
while ((poFeature = layer->GetNextFeature()) != NULL)
while ((poFeature = layer->GetNextFeature()) != nullptr)
{
OGRGeometry* geom = poFeature->GetGeometryRef();
if (geom && ! geom->IsEmpty())

View file

@ -68,7 +68,7 @@ ogr_featureset::~ogr_featureset()
feature_ptr ogr_featureset::next()
{
OGRFeature *poFeature;
while ((poFeature = layer_.GetNextFeature()) != NULL)
while ((poFeature = layer_.GetNextFeature()) != nullptr)
{
// ogr feature ids start at 0, so add one to stay
// consistent with other mapnik datasources that start at 1

View file

@ -104,7 +104,7 @@ feature_ptr ogr_index_featureset<filterT>::next()
layer_.SetNextByIndex (pos);
OGRFeature *poFeature = layer_.GetNextFeature();
if (poFeature == NULL)
if (poFeature == nullptr)
{
return feature_ptr();
}

View file

@ -36,8 +36,8 @@ class ogr_layer_ptr
{
public:
ogr_layer_ptr()
: datasource_(NULL),
layer_(NULL),
: datasource_(nullptr),
layer_(nullptr),
owns_layer_(false),
is_valid_(false)
{
@ -50,13 +50,13 @@ public:
void free_layer()
{
if (owns_layer_ && layer_ != NULL && datasource_ != NULL)
if (owns_layer_ && layer_ != nullptr && datasource_ != nullptr)
{
datasource_->ReleaseResultSet(layer_);
}
datasource_ = NULL;
layer_ = NULL;
datasource_ = nullptr;
layer_ = nullptr;
layer_name_ = "";
owns_layer_ = false;
is_valid_ = false;
@ -122,8 +122,8 @@ public:
// http://trac.osgeo.org/gdal/wiki/rfc29_desired_fields
// http://trac.osgeo.org/gdal/wiki/rfc28_sqlfunc
OGRGeometry* spatial_filter = NULL;
const char* sql_dialect = NULL;
OGRGeometry* spatial_filter = nullptr;
const char* sql_dialect = nullptr;
OGRLayer* ogr_layer = datasource_->ExecuteSQL(layer_sql.c_str(), spatial_filter, sql_dialect);
if (ogr_layer)

View file

@ -37,13 +37,13 @@ CURL_LOAD_DATA* grab_http_response(const char* url)
curl_easy_cleanup(curl);
return data;
}
return NULL;
return nullptr;
}
CURL_LOAD_DATA* do_grab(CURL* curl,const char* url)
{
CURL_LOAD_DATA* data = (CURL_LOAD_DATA*)malloc(sizeof(CURL_LOAD_DATA));
data->data = NULL;
data->data = nullptr;
data->nbytes = 0;
curl_easy_setopt(curl, CURLOPT_URL, url);

View file

@ -31,14 +31,14 @@
#include "dataset_deliverer.h"
#include "basiccurl.h"
osm_dataset * dataset_deliverer::dataset = NULL;
osm_dataset * dataset_deliverer::dataset = nullptr;
std::string dataset_deliverer::last_bbox = "";
std::string dataset_deliverer::last_filename = "";
osm_dataset* dataset_deliverer::load_from_file(const string& file, const string& parser)
{
// Only actually load from file if we haven't done so already
if (dataset == NULL)
if (dataset == nullptr)
{
if (!mapnik::util::exists(file))
{
@ -48,7 +48,7 @@ osm_dataset* dataset_deliverer::load_from_file(const string& file, const string&
dataset = new osm_dataset;
if (dataset->load(file.c_str(), parser) == false)
{
return NULL;
return nullptr;
}
atexit(dataset_deliverer::release);
@ -59,7 +59,7 @@ osm_dataset* dataset_deliverer::load_from_file(const string& file, const string&
dataset = new osm_dataset;
if (dataset->load(file.c_str(), parser) == false)
{
return NULL;
return nullptr;
}
last_filename = file;
}
@ -68,12 +68,12 @@ osm_dataset* dataset_deliverer::load_from_file(const string& file, const string&
osm_dataset* dataset_deliverer::load_from_url(const string& url, const string& bbox, const string& parser)
{
if (dataset == NULL)
if (dataset == nullptr)
{
dataset = new osm_dataset;
if (dataset->load_from_url(url.c_str(), bbox, parser) == false)
{
return NULL;
return nullptr;
}
atexit(dataset_deliverer::release);
@ -87,7 +87,7 @@ osm_dataset* dataset_deliverer::load_from_url(const string& url, const string& b
dataset->clear();
if (dataset->load_from_url(url.c_str(), bbox, parser) == false)
{
return NULL;
return nullptr;
}
last_bbox = bbox;

View file

@ -62,7 +62,7 @@ bool osm_dataset::load_from_url(std::string const& url,
CURL_LOAD_DATA* resp = grab_http_response(str.str().c_str());
if (resp != NULL)
if (resp != nullptr)
{
char *blx = new char[resp->nbytes + 1];
std::memcpy(blx, resp->data, resp->nbytes);
@ -91,7 +91,7 @@ void osm_dataset::clear()
for (unsigned int count = 0; count < ways.size(); ++count)
{
delete ways[count];
ways[count] = NULL;
ways[count] = nullptr;
}
ways.clear();
@ -99,7 +99,7 @@ void osm_dataset::clear()
for (unsigned int count = 0; count < nodes.size(); ++count)
{
delete nodes[count];
nodes[count] = NULL;
nodes[count] = nullptr;
}
nodes.clear();
@ -142,7 +142,7 @@ osm_node* osm_dataset::next_node()
{
return *(node_i++);
}
return NULL;
return nullptr;
}
osm_way* osm_dataset::next_way()
@ -151,16 +151,16 @@ osm_way* osm_dataset::next_way()
{
return *(way_i++);
}
return NULL;
return nullptr;
}
osm_item* osm_dataset::next_item()
{
osm_item* item = NULL;
osm_item* item = nullptr;
if (next_item_mode == Node)
{
item = next_node();
if (item == NULL)
if (item == nullptr)
{
next_item_mode = Way;
rewind_ways();
@ -226,7 +226,7 @@ std::string osm_way::to_string()
for (unsigned int count = 0; count < nodes.size(); ++count)
{
if (nodes[count] != NULL)
if (nodes[count] != nullptr)
{
strm << nodes[count]->id << " ";
}

View file

@ -54,7 +54,7 @@ osm_datasource::osm_datasource(const parameters& params)
type_(datasource::Vector),
desc_(*params.get<std::string>("type"), *params.get<std::string>("encoding", "utf-8"))
{
osm_data_ = NULL;
osm_data_ = nullptr;
std::string osm_filename = *params.get<std::string>("file", "");
std::string parser = *params.get<std::string>("parser", "libxml2");
std::string url = *params.get<std::string>("url", "");
@ -66,7 +66,7 @@ osm_datasource::osm_datasource(const parameters& params)
// if we supplied a url and a bounding box, load from the url
MAPNIK_LOG_DEBUG(osm) << "osm_datasource: loading_from_url url=" << url << ",bbox=" << bbox;
if ((osm_data_ = dataset_deliverer::load_from_url(url, bbox, parser)) == NULL)
if ((osm_data_ = dataset_deliverer::load_from_url(url, bbox, parser)) == nullptr)
{
throw datasource_exception("Error loading from URL");
}
@ -74,7 +74,7 @@ osm_datasource::osm_datasource(const parameters& params)
else if (osm_filename != "")
{
// if we supplied a filename, load from file
if ((osm_data_ = dataset_deliverer::load_from_file(osm_filename, parser)) == NULL)
if ((osm_data_ = dataset_deliverer::load_from_file(osm_filename, parser)) == nullptr)
{
std::string s("OSM Plugin: Error loading from file '");
s += osm_filename + "'";

View file

@ -6,17 +6,17 @@
#include <cassert>
#include <mapnik/util/conversions.hpp>
osm_item* osmparser::cur_item=NULL;
osm_item* osmparser::cur_item=nullptr;
mapnik::value_integer osmparser::curID=0;
bool osmparser::in_node=false, osmparser::in_way=false;
osm_dataset* osmparser::components=NULL;
osm_dataset* osmparser::components=nullptr;
std::string osmparser::error="";
std::map<mapnik::value_integer,osm_node*> osmparser::tmp_node_store=std::map<mapnik::value_integer,osm_node*>();
void osmparser::processNode(xmlTextReaderPtr reader)
{
xmlChar *name = xmlTextReaderName(reader);
if(name==NULL)
if(name==nullptr)
name=xmlStrdup(BAD_CAST "--");
switch(xmlTextReaderNodeType(reader))
@ -127,7 +127,7 @@ bool osmparser::parse(osm_dataset *ds,char* data, int nbytes)
// libxml2.html, converted from Objective-C to straight C
components=ds;
xmlTextReaderPtr reader = xmlReaderForMemory(data,nbytes,NULL,NULL,0);
xmlTextReaderPtr reader = xmlReaderForMemory(data,nbytes,nullptr,nullptr,0);
int ret=do_parse(reader);
xmlFreeTextReader(reader);
return (ret==0) ? true:false;
@ -137,7 +137,7 @@ bool osmparser::parse(osm_dataset *ds,char* data, int nbytes)
int osmparser::do_parse(xmlTextReaderPtr reader)
{
int ret=-1;
if(reader!=NULL)
if(reader!=nullptr)
{
ret = xmlTextReaderRead(reader);
while(ret==1)

View file

@ -11,7 +11,7 @@ int main(int argc,char* argv[])
bounds b = dataset.get_bounds();
osm_item *item;
dataset.rewind();
while((item=dataset.next_item())!=NULL)
while((item=dataset.next_item())!=nullptr)
{
std::cerr << item->to_string() << endl;
}

View file

@ -191,7 +191,7 @@ postgis_datasource::postgis_datasource(parameters const& params)
if (srid_ == 0)
{
const char* srid_c = rs->getValue("srid");
if (srid_c != NULL)
if (srid_c != nullptr)
{
int result = 0;
const char * end = srid_c + std::strlen(srid_c);
@ -223,7 +223,7 @@ postgis_datasource::postgis_datasource(parameters const& params)
if (rs->next())
{
const char* srid_c = rs->getValue("srid");
if (srid_c != NULL)
if (srid_c != nullptr)
{
int result = 0;
const char * end = srid_c + std::strlen(srid_c);

View file

@ -91,7 +91,7 @@ std::string logger::str()
logger::format_env_check_ = false;
const char* log_format = getenv("MAPNIK_LOG_FORMAT");
if (log_format != NULL)
if (log_format != nullptr)
{
logger::format_ = log_format;
}

View file

@ -47,7 +47,7 @@ namespace mapnik
{
freetype_engine::freetype_engine() :
library_(NULL)
library_(nullptr)
{
FT_Error error = FT_Init_FreeType( &library_ );

View file

@ -46,7 +46,7 @@ namespace mapnik
class libxml2_loader : mapnik::noncopyable
{
public:
libxml2_loader(const char *encoding = NULL, int options = DEFAULT_OPTIONS, const char *url = NULL) :
libxml2_loader(const char *encoding = nullptr, int options = DEFAULT_OPTIONS, const char *url = nullptr) :
ctx_(0),
encoding_(encoding),
options_(options),

View file

@ -45,8 +45,8 @@ namespace mapnik { namespace MiniZ {
PNGWriter::PNGWriter(int level, int strategy)
{
buffer = NULL;
compressor = NULL;
buffer = nullptr;
compressor = nullptr;
if (level == -1)
{
@ -63,22 +63,22 @@ PNGWriter::PNGWriter(int level, int strategy)
else if (strategy == Z_FIXED) flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS;
buffer = (tdefl_output_buffer *)MZ_MALLOC(sizeof(tdefl_output_buffer));
if (buffer == NULL)
if (buffer == nullptr)
{
throw std::bad_alloc();
}
buffer->m_pBuf = NULL;
buffer->m_pBuf = nullptr;
buffer->m_capacity = 8192;
buffer->m_expandable = MZ_TRUE;
buffer->m_pBuf = (mz_uint8 *)MZ_MALLOC(buffer->m_capacity);
if (buffer->m_pBuf == NULL)
if (buffer->m_pBuf == nullptr)
{
throw std::bad_alloc();
}
compressor = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor));
if (compressor == NULL)
if (compressor == nullptr)
{
throw std::bad_alloc();
}
@ -256,7 +256,7 @@ void PNGWriter::writeIDAT(T const& image)
}
}
status = tdefl_compress_buffer(compressor, NULL, 0, TDEFL_FINISH);
status = tdefl_compress_buffer(compressor, nullptr, 0, TDEFL_FINISH);
if (status != TDEFL_STATUS_DONE)
{
throw std::runtime_error("failed to compress image");
@ -303,7 +303,7 @@ void PNGWriter::writeIDATStripAlpha(T const& image) {
MZ_FREE(scanline);
status = tdefl_compress_buffer(compressor, NULL, 0, TDEFL_FINISH);
status = tdefl_compress_buffer(compressor, nullptr, 0, TDEFL_FINISH);
if (status != TDEFL_STATUS_DONE) throw std::runtime_error("failed to compress image");
finishChunk(IDAT);

View file

@ -50,8 +50,8 @@ namespace mapnik {
projection::projection(std::string const& params, bool defer_proj_init)
: params_(params),
defer_proj_init_(defer_proj_init),
proj_(NULL),
proj_ctx_(NULL)
proj_(nullptr),
proj_ctx_(nullptr)
{
boost::optional<bool> is_known = is_known_geographic(params_);
if (is_known){
@ -72,8 +72,8 @@ projection::projection(projection const& rhs)
: params_(rhs.params_),
defer_proj_init_(rhs.defer_proj_init_),
is_geographic_(rhs.is_geographic_),
proj_(NULL),
proj_ctx_(NULL)
proj_(nullptr),
proj_ctx_(nullptr)
{
if (!defer_proj_init_) init_proj4();
}

View file

@ -1,5 +1,3 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
@ -44,7 +42,7 @@ namespace mapnik
class rapidxml_loader : mapnik::noncopyable
{
public:
rapidxml_loader(const char *encoding = NULL) :
rapidxml_loader(const char *encoding = nullptr) :
filename_()
{

View file

@ -1054,7 +1054,7 @@ svg_parser::~svg_parser() {}
void svg_parser::parse(std::string const& filename)
{
xmlTextReaderPtr reader = xmlNewTextReaderFilename(filename.c_str());
if (reader == NULL)
if (reader == nullptr)
{
MAPNIK_LOG_ERROR(svg_parser) << "Unable to open '" << filename << "'";
}
@ -1066,9 +1066,9 @@ void svg_parser::parse(std::string const& filename)
void svg_parser::parse_from_string(std::string const& svg)
{
xmlTextReaderPtr reader = xmlReaderForMemory(svg.c_str(),svg.size(),NULL,NULL,
xmlTextReaderPtr reader = xmlReaderForMemory(svg.c_str(),svg.size(),nullptr,nullptr,
(XML_PARSE_NOBLANKS | XML_PARSE_NOCDATA | XML_PARSE_NOERROR | XML_PARSE_NOWARNING));
if (reader == NULL)
if (reader == nullptr)
{
MAPNIK_LOG_ERROR(svg_parser) << "Unable to parse '" << svg << "'";
}

View file

@ -69,7 +69,7 @@ void text_node::apply(char_properties_ptr p, feature_impl const& feature, text_l
else if (p->text_transform == CAPITALIZE)
{
// note: requires BreakIterator support in ICU which is optional
text_str = text_str.toTitle(NULL);
text_str = text_str.toTitle(nullptr);
}
#endif
if (text_str.length() > 0) {

View file

@ -75,7 +75,7 @@ void reproject_and_scale_raster(raster & target, raster const& source,
ts.backward(&xs(i,j), &ys(i,j));
}
}
prj_trans.backward(xs.getData(), ys.getData(), NULL, mesh_nx*mesh_ny);
prj_trans.backward(xs.getData(), ys.getData(), nullptr, mesh_nx*mesh_ny);
// Initialize AGG objects
typedef agg::pixfmt_rgba32_pre pixfmt;

View file

@ -85,7 +85,7 @@ namespace mapnik { namespace sqlite {
{
if (sqlite3_bind_null(stmt_, index_) != SQLITE_OK)
{
std::cerr << "cannot bind NULL\n";
std::cerr << "cannot bind nullptr\n";
return false;
}
return true;