+ remove boost::iostreams dependency

This commit is contained in:
Artem Pavlenko 2011-04-07 13:35:21 +00:00
parent 0e0b7a578c
commit e81761d270
5 changed files with 17 additions and 37 deletions

View file

@ -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)

View file

@ -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')

View file

@ -27,8 +27,6 @@
// boost
#include <boost/algorithm/string.hpp>
#include <boost/spirit/include/qi.hpp>
//#include <boost/interprocess/file_mapping.hpp>
//#include <boost/interprocess/mapped_region.hpp>
#include <mapnik/mapped_memory_cache.hpp>
// stl
#include <string>
@ -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_);

View file

@ -26,21 +26,16 @@
#include <mapnik/feature.hpp>
// boost
#include <boost/utility.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/file.hpp>
//
#include <boost/interprocess/streams/bufferstream.hpp>
//#include <boost/iostreams/device/mapped_file.hpp>
// stl
#include <vector>
#include <string>
#include <cassert>
#include <fstream>
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<field_descriptor> fields_;
#ifdef SHAPE_MEMORY_MAPPED_FILE
//stream<mapped_file_source> file_;
boost::interprocess::ibufferstream file_;
#else
stream<file_source> file_;
std::ifstream file_;
#endif
char* record_;
public:

View file

@ -31,17 +31,10 @@
// boost
#include <boost/utility.hpp>
#include <boost/cstdint.hpp>
#include <boost/interprocess/streams/bufferstream.hpp>
//#include <boost/interprocess/file_mapping.hpp>
//#include <boost/interprocess/mapped_region.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/iostreams/device/file.hpp>
//#include <boost/iostreams/device/mapped_file.hpp>
// stl
#include <cstring>
#include <fstream>
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<mapped_file_source> file_source_type;
typedef ibufferstream file_source_type;
typedef shape_record<MappedRecordTag> record_type;
//typedef boost::shared_ptr<mapped_region> mapped_region_ptr;
//mapped_region_ptr region_;
#else
typedef stream<file_source> file_source_type;
typedef std::ifstream file_source_type;
typedef shape_record<RecordTag> 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<mapnik::mapped_region_ptr> memory = mapnik::mapped_memory_cache::find(file_name.c_str(),true);
if (memory)
{