From e81761d270eed96e743e5d31da8acc376f3a491c Mon Sep 17 00:00:00 2001 From: Artem Pavlenko Date: Thu, 7 Apr 2011 13:35:21 +0000 Subject: [PATCH] + remove boost::iostreams dependency --- SConstruct | 4 ++-- plugins/input/shape/SConscript | 2 +- plugins/input/shape/dbffile.cpp | 12 +++++------- plugins/input/shape/dbffile.hpp | 14 ++++---------- plugins/input/shape/shapefile.hpp | 22 +++++----------------- 5 files changed, 17 insertions(+), 37 deletions(-) diff --git a/SConstruct b/SConstruct index 153931270..914a4d001 100644 --- a/SConstruct +++ b/SConstruct @@ -1035,7 +1035,7 @@ if not preconfigured: ['system', 'boost/system/system_error.hpp', env['HAS_BOOST_SYSTEM']], ['filesystem', 'boost/filesystem/operations.hpp', True], ['regex', 'boost/regex.hpp', True], - ['iostreams','boost/iostreams/device/mapped_file.hpp',True], + #['iostreams','boost/iostreams/device/mapped_file.hpp',True], ['program_options', 'boost/program_options.hpp', False] ] @@ -1263,7 +1263,7 @@ if not preconfigured: env.Append(CXXFLAGS = common_cxx_flags + '-O %s' % ndebug_flags) else: # Common flags for GCC. - gcc_cxx_flags = '-ansi -Wall %s -ftemplate-depth-200 %s' % (pthread, common_cxx_flags) + gcc_cxx_flags = '-ansi -Wall -Wno-parentheses -Wno-unused-function -Wno-char-subscripts %s -ftemplate-depth-200 %s' % (pthread, common_cxx_flags) if env['DEBUG']: env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline %s' % debug_flags) diff --git a/plugins/input/shape/SConscript b/plugins/input/shape/SConscript index f93c87eba..54d8b53f8 100644 --- a/plugins/input/shape/SConscript +++ b/plugins/input/shape/SConscript @@ -37,7 +37,7 @@ shape_src = Split( """ ) -libraries = ['boost_iostreams%s' % env['BOOST_APPEND']] +libraries = [] #['boost_iostreams%s' % env['BOOST_APPEND']] if env['PLATFORM'] == 'Darwin': libraries.append('mapnik2') diff --git a/plugins/input/shape/dbffile.cpp b/plugins/input/shape/dbffile.cpp index 90e0fd16e..46fd0a8df 100644 --- a/plugins/input/shape/dbffile.cpp +++ b/plugins/input/shape/dbffile.cpp @@ -27,8 +27,6 @@ // boost #include #include -//#include -//#include #include // stl #include @@ -47,7 +45,7 @@ dbf_file::dbf_file(std::string const& file_name) #ifdef SHAPE_MEMORY_MAPPED_FILE file_(), #else - file_(file_name,std::ios::in | std::ios::binary), + file_(file_name.c_str() ,std::ios::in | std::ios::binary), #endif record_(0) { @@ -97,7 +95,7 @@ void dbf_file::move_to(int index) { if (index>0 && index<=num_records_) { - stream_offset pos=(num_fields_<<5)+34+(index-1)*(record_length_+1); + std::streampos pos=(num_fields_<<5)+34+(index-1)*(record_length_+1); file_.seekg(pos,std::ios::beg); file_.read(record_,record_length_); } @@ -136,9 +134,9 @@ void dbf_file::add_attribute(int col, mapnik::transcoder const& tr, Feature cons case 'M': case 'L': { - // FIXME - avoid constructing std::string in stack + // FIXME - avoid constructing std::string on stack std::string str(record_+fields_[col].offset_,fields_[col].length_); - boost::trim(str); + boost::trim(str); f[name] = tr.transcode(str.c_str()); break; } @@ -185,7 +183,7 @@ void dbf_file::read_header() assert(num_fields_>0); num_fields_=(num_fields_-33)/32; skip(22); - stream_offset offset=0; + std::streampos offset=0; char name[11]; memset(&name,0,11); fields_.reserve(num_fields_); diff --git a/plugins/input/shape/dbffile.hpp b/plugins/input/shape/dbffile.hpp index b3120692b..f2e4e3dab 100644 --- a/plugins/input/shape/dbffile.hpp +++ b/plugins/input/shape/dbffile.hpp @@ -26,21 +26,16 @@ #include // boost #include -#include -#include -// #include -//#include // stl #include #include #include - +#include using mapnik::transcoder; using mapnik::Feature; -using namespace boost::iostreams; struct field_descriptor { @@ -49,7 +44,7 @@ struct field_descriptor char type_; int length_; int dec_; - stream_offset offset_; + std::streampos offset_; }; @@ -58,13 +53,12 @@ class dbf_file : private boost::noncopyable private: int num_records_; int num_fields_; - stream_offset record_length_; + std::size_t record_length_; std::vector fields_; #ifdef SHAPE_MEMORY_MAPPED_FILE - //stream file_; boost::interprocess::ibufferstream file_; #else - stream file_; + std::ifstream file_; #endif char* record_; public: diff --git a/plugins/input/shape/shapefile.hpp b/plugins/input/shape/shapefile.hpp index 0c28170d6..d7b5ff55c 100644 --- a/plugins/input/shape/shapefile.hpp +++ b/plugins/input/shape/shapefile.hpp @@ -31,17 +31,10 @@ // boost #include #include - #include - -//#include -//#include - -#include -#include -//#include - +// stl #include +#include using mapnik::box2d; using mapnik::read_int32_ndr; @@ -133,7 +126,6 @@ struct shape_record }; -using namespace boost::iostreams; using namespace boost::interprocess; class shape_file : boost::noncopyable @@ -141,13 +133,10 @@ class shape_file : boost::noncopyable public: #ifdef SHAPE_MEMORY_MAPPED_FILE - //typedef stream file_source_type; typedef ibufferstream file_source_type; typedef shape_record record_type; - //typedef boost::shared_ptr mapped_region_ptr; - //mapped_region_ptr region_; #else - typedef stream file_source_type; + typedef std::ifstream file_source_type; typedef shape_record record_type; #endif @@ -159,12 +148,11 @@ public: #ifdef SHAPE_MEMORY_MAPPED_FILE file_() #else - file_(file_name,std::ios::in | std::ios::binary) + file_(file_name.c_str(), std::ios::in | std::ios::binary) #endif { #ifdef SHAPE_MEMORY_MAPPED_FILE - //file_mapping mapping(file_name.c_str(),read_only); - //region_ = mapped_region_ptr(new mapped_region(mapping, read_only)); + boost::optional memory = mapnik::mapped_memory_cache::find(file_name.c_str(),true); if (memory) {