+ add support for boost::filesystem v3

(http://www.boost.org/doc/libs/1_45_0/libs/filesystem/v3/doc/deprecated.html)
This commit is contained in:
Artem Pavlenko 2011-01-04 15:22:49 +00:00
parent 71356d8d35
commit be458e7ac0
3 changed files with 122 additions and 85 deletions

View file

@ -40,8 +40,8 @@
namespace mapnik
{
using namespace std;
using namespace boost;
//using namespace std;
//using namespace boost;
bool is_input_plugin (std::string const& filename)
{
@ -73,7 +73,7 @@ datasource_ptr datasource_cache::create(const parameters& params, bool bind)
}
datasource_ptr ds;
map<string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(*type);
std::map<string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(*type);
if ( itr == plugins_.end() )
{
throw config_error(string("Could not create datasource. No plugin ") +
@ -137,19 +137,23 @@ void datasource_cache::register_datasources(const std::string& str)
mutex::scoped_lock lock(mapnik::singleton<mapnik::datasource_cache,
mapnik::CreateStatic>::mutex_);
#endif
filesystem::path path(str);
boost::filesystem::path path(str);
plugin_directories_.push_back(str);
filesystem::directory_iterator end_itr;
boost::filesystem::directory_iterator end_itr;
if (exists(path) && is_directory(path))
{
for (filesystem::directory_iterator itr(path);itr!=end_itr;++itr )
for (boost::filesystem::directory_iterator itr(path);itr!=end_itr;++itr )
{
#if BOOST_VERSION < 103400
if (!is_directory( *itr ) && is_input_plugin(itr->leaf()))
#else
#if (BOOST_FILESYSTEM_VERSION == 3)
if (!is_directory( *itr ) && is_input_plugin(itr->path().filename().string()))
#else // v2
if (!is_directory( *itr ) && is_input_plugin(itr->path().leaf()))
#endif
#endif
{
try
@ -181,11 +185,21 @@ void datasource_cache::register_datasources(const std::string& str)
if (ret != 0) {
std::clog << "Datasource loader: could not intialize dynamic loading of global symbols: " << lt_dlerror() << "\n";
}
#if (BOOST_FILESYSTEM_VERSION == 3)
module = lt_dlopenadvise (itr->path().string().c_str(), advise);
#else // v2
module = lt_dlopenadvise (itr->string().c_str(), advise);
#endif
lt_dladvise_destroy(&advise);
#else
#if (BOOST_FILESYSTEM_VERSION == 3)
lt_dlhandle module = lt_dlopen(itr->path().string().c_str());
#else // v2
lt_dlhandle module = lt_dlopen(itr->string().c_str());
#endif
#endif
if (module)
{
@ -201,7 +215,13 @@ void datasource_cache::register_datasources(const std::string& str)
}
else
{
std::clog << "Problem loading plugin library: " << itr->string().c_str() << " (dlopen failed - plugin likely has an unsatified dependency or incompatible ABI)" << std::endl;
#if (BOOST_FILESYSTEM_VERSION == 3)
std::clog << "Problem loading plugin library: " << itr->path().string()
<< " (dlopen failed - plugin likely has an unsatified dependency or incompatible ABI)" << std::endl;
#else // v2
std::clog << "Problem loading plugin library: " << itr->string()
<< " (dlopen failed - plugin likely has an unsatified dependency or incompatible ABI)" << std::endl;
#endif
}
}
catch (...) {}

View file

@ -94,11 +94,19 @@ bool freetype_engine::register_fonts(std::string const& dir, bool recurse)
{
if (boost::filesystem::is_directory(*itr) && recurse)
{
if (!register_fonts(itr->string(), true)) return false;
#if (BOOST_FILESYSTEM_VERSION == 3)
if (!register_fonts(itr->path().string(), true)) return false;
#else // v2
if (!register_fonts(itr->string(), true)) return false;
#endif
}
else
{
#if (BOOST_FILESYSTEM_VERSION == 3)
mapnik::freetype_engine::register_font(itr->path().string());
#else // v2
mapnik::freetype_engine::register_font(itr->string());
#endif
}
}
return true;

View file

@ -267,73 +267,73 @@ void map_parser::parse_map( Map & map, ptree const & pt )
void map_parser::parse_map_include( Map & map, ptree const & include )
{
ptree::const_iterator itr = include.begin();
ptree::const_iterator end = include.end();
ptree::const_iterator itr = include.begin();
ptree::const_iterator end = include.end();
for (; itr != end; ++itr)
for (; itr != end; ++itr)
{
ptree::value_type const& v = *itr;
if (v.first == "Include")
{
ptree::value_type const& v = *itr;
if (v.first == "Include")
{
parse_map_include( map, v.second );
}
else if (v.first == "Style")
{
parse_style( map, v.second );
}
else if (v.first == "Layer")
{
parse_layer(map, v.second );
}
else if (v.first == "FontSet")
{
parse_fontset(map, v.second);
}
else if (v.first == "MetaWriter")
{
parse_metawriter(map, v.second);
}
else if (v.first == "FileSource")
{
std::string name = get_attr<string>( v.second, "name");
std::string value = get_value<string>( v.second, "");
file_sources_[name] = value;
}
else if (v.first == "Datasource")
{
std::string name = get_attr(v.second, "name", string("Unnamed"));
parameters params;
ptree::const_iterator paramIter = v.second.begin();
ptree::const_iterator endParam = v.second.end();
for (; paramIter != endParam; ++paramIter)
{
ptree const& param = paramIter->second;
if (paramIter->first == "Parameter")
{
std::string name = get_attr<string>(param, "name");
std::string value = get_value<string>( param,
"datasource parameter");
params[name] = value;
}
else if( paramIter->first != "<xmlattr>" &&
paramIter->first != "<xmlcomment>" )
{
throw config_error(std::string("Unknown child node in ") +
"'Datasource'. Expected 'Parameter' but got '" +
paramIter->first + "'");
}
}
datasource_templates_[name] = params;
}
else if (v.first != "<xmlcomment>" &&
v.first != "<xmlattr>")
{
throw config_error(std::string("Unknown child node in 'Map': '") +
v.first + "'");
}
parse_map_include( map, v.second );
}
else if (v.first == "Style")
{
parse_style( map, v.second );
}
else if (v.first == "Layer")
{
parse_layer(map, v.second );
}
else if (v.first == "FontSet")
{
parse_fontset(map, v.second);
}
else if (v.first == "MetaWriter")
{
parse_metawriter(map, v.second);
}
else if (v.first == "FileSource")
{
std::string name = get_attr<string>( v.second, "name");
std::string value = get_value<string>( v.second, "");
file_sources_[name] = value;
}
else if (v.first == "Datasource")
{
std::string name = get_attr(v.second, "name", string("Unnamed"));
parameters params;
ptree::const_iterator paramIter = v.second.begin();
ptree::const_iterator endParam = v.second.end();
for (; paramIter != endParam; ++paramIter)
{
ptree const& param = paramIter->second;
if (paramIter->first == "Parameter")
{
std::string name = get_attr<string>(param, "name");
std::string value = get_value<string>( param,
"datasource parameter");
params[name] = value;
}
else if( paramIter->first != "<xmlattr>" &&
paramIter->first != "<xmlcomment>" )
{
throw config_error(std::string("Unknown child node in ") +
"'Datasource'. Expected 'Parameter' but got '" +
paramIter->first + "'");
}
}
datasource_templates_[name] = params;
}
else if (v.first != "<xmlcomment>" &&
v.first != "<xmlattr>")
{
throw config_error(std::string("Unknown child node in 'Map': '") +
v.first + "'");
}
}
map.init_metawriters();
@ -614,8 +614,11 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
map.addLayer(lyr);
} catch (const config_error & ex) {
if ( ! name.empty() ) {
}
catch (const config_error & ex)
{
if ( ! name.empty() )
{
ex.append_context(std::string("(encountered during parsing of layer '") + name + "' in map '" + filename_ + "')");
}
throw;
@ -1225,12 +1228,12 @@ void map_parser::parse_text_symbolizer( rule_type & rule, ptree const & sym )
text_symbol.set_line_spacing(*line_spacing);
}
// tolerance between label spacing along line
optional<unsigned> label_position_tolerance = get_opt_attr<unsigned>(sym, "label_position_tolerance");
if (label_position_tolerance)
{
// tolerance between label spacing along line
optional<unsigned> label_position_tolerance = get_opt_attr<unsigned>(sym, "label_position_tolerance");
if (label_position_tolerance)
{
text_symbol.set_label_position_tolerance(*label_position_tolerance);
}
}
// spacing between characters in text
optional<unsigned> character_spacing = get_opt_attr<unsigned>(sym, "character_spacing");
@ -1921,8 +1924,14 @@ std::string map_parser::ensure_relative_to_xml( boost::optional<std::string> opt
{
boost::filesystem::path xml_path = filename_;
boost::filesystem::path rel_path = *opt_path;
if ( !rel_path.has_root_path() ) {
if ( !rel_path.has_root_path() )
{
#if (BOOST_FILESYSTEM_VERSION == 3)
boost::filesystem::path full = boost::filesystem::absolute(xml_path.branch_path()/rel_path).normalize();
#else // v2
boost::filesystem::path full = boost::filesystem::complete(xml_path.branch_path()/rel_path).normalize();
#endif
#ifdef MAPNIK_DEBUG
std::clog << "\nModifying relative paths to be relative to xml...\n";
std::clog << "original base path: " << *opt_path << "\n";