From 6f24bd1c0124200859f7cf654a1a51cc7e4b9eaf Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 15 May 2014 13:52:43 +0100 Subject: [PATCH 1/3] mapnik c++ style --- src/font_engine_freetype.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 761413c42..8e332141a 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -73,10 +73,9 @@ void init_freetype(FT_Memory memory, FT_Library & library) FT_Add_Default_Modules(library); } -freetype_engine::freetype_engine() : - library_(nullptr), - memory_(new FT_MemoryRec_) - +freetype_engine::freetype_engine() + : library_(nullptr), + memory_(new FT_MemoryRec_) { init_freetype(&*memory_, library_); } @@ -313,10 +312,9 @@ stroker_ptr freetype_engine::create_stroker() template -face_ptr face_manager::get_face(const std::string &name) +face_ptr face_manager::get_face(std::string const& name) { - face_ptr_cache_type::iterator itr; - itr = face_ptr_cache_.find(name); + auto itr = face_ptr_cache_.find(name); if (itr != face_ptr_cache_.end()) { return itr->second; @@ -333,7 +331,7 @@ face_ptr face_manager::get_face(const std::string &name) } template -face_set_ptr face_manager::get_face_set(const std::string &name) +face_set_ptr face_manager::get_face_set(std::string const& name) { face_set_ptr face_set = std::make_shared(); if (face_ptr face = get_face(name)) @@ -344,7 +342,7 @@ face_set_ptr face_manager::get_face_set(const std::string &name) } template -face_set_ptr face_manager::get_face_set(const font_set &fset) +face_set_ptr face_manager::get_face_set(font_set const& fset) { std::vector const& names = fset.get_face_names(); face_set_ptr face_set = std::make_shared(); From 3cc8fad956de35147cd415ef69a10c70afc3ceb0 Mon Sep 17 00:00:00 2001 From: artemp Date: Thu, 15 May 2014 14:00:46 +0100 Subject: [PATCH 2/3] c++11 syntax --- src/font_engine_freetype.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 8e332141a..42c5e8afe 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -235,10 +235,9 @@ bool freetype_engine::register_fonts_impl(std::string const& dir, FT_LibraryRec_ std::vector freetype_engine::face_names () { std::vector names; - std::map >::const_iterator itr; - for (itr = name2file_.begin();itr!=name2file_.end();++itr) + for (auto const& kv : name2file_) { - names.push_back(itr->first); + names.push_back(kv.first); } return names; } @@ -251,13 +250,12 @@ std::map > const& freetype_engine::get_ma face_ptr freetype_engine::create_face(std::string const& family_name) { - std::map >::const_iterator itr; - itr = name2file_.find(family_name); + auto itr = name2file_.find(family_name); if (itr != name2file_.end()) { FT_Face face; - std::map::const_iterator mem_font_itr = memory_fonts_.find(itr->second.second); + auto mem_font_itr = memory_fonts_.find(itr->second.second); if (mem_font_itr != memory_fonts_.end()) // memory font { @@ -278,8 +276,7 @@ face_ptr freetype_engine::create_face(std::string const& family_name) std::ifstream is(itr->second.second.c_str() , std::ios::binary); std::string buffer((std::istreambuf_iterator(is)), std::istreambuf_iterator()); - std::pair::iterator,bool> result - = memory_fonts_.insert(std::make_pair(itr->second.second, buffer)); + auto result = memory_fonts_.insert(std::make_pair(itr->second.second, buffer)); FT_Error error = FT_New_Memory_Face (library_, reinterpret_cast(result.first->second.c_str()), @@ -346,9 +343,9 @@ face_set_ptr face_manager::get_face_set(font_set const& fset) { std::vector const& names = fset.get_face_names(); face_set_ptr face_set = std::make_shared(); - for (std::vector::const_iterator name = names.begin(); name != names.end(); ++name) + for (auto const& name : names) { - face_ptr face = get_face(*name); + face_ptr face = get_face(name); if (face) { face_set->add(face); From a6a3af02d9fb44a61b036d3a97cf2cc368329fdd Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 16 May 2014 11:18:27 +0100 Subject: [PATCH 3/3] relax FeatureCollection grammar to allow arbitary key:value's --- include/mapnik/json/feature_collection_grammar.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/json/feature_collection_grammar.hpp b/include/mapnik/json/feature_collection_grammar.hpp index 86d7a4a52..26ab71b6f 100644 --- a/include/mapnik/json/feature_collection_grammar.hpp +++ b/include/mapnik/json/feature_collection_grammar.hpp @@ -81,7 +81,7 @@ struct feature_collection_grammar : start = feature_collection | feature_from_geometry(_val) | feature(_val) ; - feature_collection = lit('{') >> (type | features) % lit(',') >> lit('}') + feature_collection = lit('{') >> (type | features | json.key_value) % lit(',') >> lit('}') ; type = lit("\"type\"") >> lit(':') >> lit("\"FeatureCollection\"")