use std::string

This commit is contained in:
Dane Springmeyer 2011-06-24 00:53:00 +00:00
parent 45965381af
commit e94667a8ae
4 changed files with 71 additions and 70 deletions

View file

@ -37,6 +37,7 @@
// stl
#include <algorithm>
#include <iostream>
#include <stdexcept>
namespace mapnik
@ -58,7 +59,7 @@ datasource_cache::~datasource_cache()
lt_dlexit();
}
std::map<string,boost::shared_ptr<PluginInfo> > datasource_cache::plugins_;
std::map<std::string,boost::shared_ptr<PluginInfo> > datasource_cache::plugins_;
bool datasource_cache::registered_=false;
std::vector<std::string> datasource_cache::plugin_directories_;
@ -67,20 +68,20 @@ datasource_ptr datasource_cache::create(const parameters& params, bool bind)
boost::optional<std::string> type = params.get<std::string>("type");
if ( ! type)
{
throw config_error(string("Could not create datasource. Required ") +
throw config_error(std::string("Could not create datasource. Required ") +
"parameter 'type' is missing");
}
datasource_ptr ds;
std::map<string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(*type);
std::map<std::string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(*type);
if ( itr == plugins_.end() )
{
throw config_error(string("Could not create datasource. No plugin ") +
throw config_error(std::string("Could not create datasource. No plugin ") +
"found for type '" + * type + "' (searched in: " + plugin_directories() + ")");
}
if ( ! itr->second->handle())
{
throw std::runtime_error(string("Cannot load library: ") +
throw std::runtime_error(std::string("Cannot load library: ") +
lt_dlerror());
}
// http://www.mr-edd.co.uk/blog/supressing_gcc_warnings
@ -92,7 +93,7 @@ datasource_ptr datasource_cache::create(const parameters& params, bool bind)
if ( ! create_datasource)
{
throw std::runtime_error(string("Cannot load symbols: ") +
throw std::runtime_error(std::string("Cannot load symbols: ") +
lt_dlerror());
}
#ifdef MAPNIK_DEBUG

View file

@ -116,7 +116,7 @@ void save_to_stream(T const& image,
if (type.length() > 6){
boost::char_separator<char> sep(":");
boost::tokenizer< boost::char_separator<char> > tokens(type, sep);
BOOST_FOREACH(string t, tokens)
BOOST_FOREACH(std::string t, tokens)
{
if (t == "m=h")
{

View file

@ -97,7 +97,7 @@ void layer::set_name( std::string const& name)
name_ = name;
}
string const& layer::name() const
std::string const& layer::name() const
{
return name_;
}
@ -107,7 +107,7 @@ void layer::set_title( std::string const& title)
title_ = title;
}
string const& layer::title() const
std::string const& layer::title() const
{
return title_;
}
@ -117,7 +117,7 @@ void layer::set_abstract( std::string const& abstract)
abstract_ = abstract;
}
string const& layer::abstract() const
std::string const& layer::abstract() const
{
return abstract_;
}

View file

@ -229,7 +229,7 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base
map.set_background( * bgcolor );
}
optional<std::string> image_filename = get_opt_attr<string>(map_node, "background-image");
optional<std::string> image_filename = get_opt_attr<std::string>(map_node, "background-image");
if (image_filename)
{
map.set_background_image(ensure_relative_to_xml(image_filename));
@ -356,13 +356,13 @@ void map_parser::parse_map_include( Map & map, ptree const & include )
}
else if (v.first == "FileSource")
{
std::string name = get_attr<string>( v.second, "name");
std::string value = get_value<string>( v.second, "");
std::string name = get_attr<std::string>( v.second, "name");
std::string value = get_value<std::string>( v.second, "");
file_sources_[name] = value;
}
else if (v.first == "Datasource")
{
std::string name = get_attr(v.second, "name", string("Unnamed"));
std::string name = get_attr(v.second, "name", std::string("Unnamed"));
parameters params;
ptree::const_iterator paramIter = v.second.begin();
ptree::const_iterator endParam = v.second.end();
@ -372,8 +372,8 @@ void map_parser::parse_map_include( Map & map, ptree const & include )
if (paramIter->first == "Parameter")
{
std::string name = get_attr<string>(param, "name");
std::string value = get_value<string>( param,
std::string name = get_attr<std::string>(param, "name");
std::string value = get_value<std::string>( param,
"datasource parameter");
params[name] = value;
}
@ -406,10 +406,10 @@ void map_parser::parse_style( Map & map, ptree const & sty )
<< "filter-mode";
ensure_attrs(sty, "Style", s.str());
string name("<missing name>");
std::string name("<missing name>");
try
{
name = get_attr<string>(sty, "name");
name = get_attr<std::string>(sty, "name");
feature_type_style style;
filter_mode_e filter_mode = get_attr<filter_mode_e>(sty, "filter-mode", FILTER_ALL);
@ -437,9 +437,9 @@ void map_parser::parse_style( Map & map, ptree const & sty )
} catch (const config_error & ex) {
if ( ! name.empty() ) {
ex.append_context(string("in style '") + name + "'");
ex.append_context(std::string("in style '") + name + "'");
}
ex.append_context(string("in map '") + filename_ + "'");
ex.append_context(std::string("in map '") + filename_ + "'");
throw;
}
}
@ -447,19 +447,19 @@ void map_parser::parse_style( Map & map, ptree const & sty )
void map_parser::parse_metawriter(Map & map, ptree const & pt)
{
ensure_attrs(pt, "MetaWriter", "name,type,file,default-output,output-empty");
string name("<missing name>");
std::string name("<missing name>");
metawriter_ptr writer;
try
{
name = get_attr<string>(pt, "name");
name = get_attr<std::string>(pt, "name");
writer = metawriter_create(pt);
map.insert_metawriter(name, writer);
} catch (const config_error & ex) {
if (!name.empty()) {
ex.append_context(string("in meta writer '") + name + "'");
ex.append_context(std::string("in meta writer '") + name + "'");
}
ex.append_context(string("in map '") + filename_ + "'");
ex.append_context(std::string("in map '") + filename_ + "'");
throw;
}
}
@ -467,10 +467,10 @@ void map_parser::parse_metawriter(Map & map, ptree const & pt)
void map_parser::parse_fontset( Map & map, ptree const & fset )
{
ensure_attrs(fset, "FontSet", "name,Font");
string name("<missing name>");
std::string name("<missing name>");
try
{
name = get_attr<string>(fset, "name");
name = get_attr<std::string>(fset, "name");
font_set fontset(name);
ptree::const_iterator itr = fset.begin();
@ -499,9 +499,9 @@ void map_parser::parse_fontset( Map & map, ptree const & fset )
fontsets_.insert(pair<std::string, font_set>(name, fontset));
} catch (const config_error & ex) {
if ( ! name.empty() ) {
ex.append_context(string("in FontSet '") + name + "'");
ex.append_context(std::string("in FontSet '") + name + "'");
}
ex.append_context(string("in map '") + filename_ + "'");
ex.append_context(std::string("in map '") + filename_ + "'");
throw;
}
}
@ -510,7 +510,7 @@ void map_parser::parse_font(font_set & fset, ptree const & f)
{
ensure_attrs(f, "Font", "face-name");
std::string face_name = get_attr(f, "face-name", string());
std::string face_name = get_attr(f, "face-name", std::string());
if ( strict_ )
{
@ -536,7 +536,7 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
ensure_attrs(lay, "Layer", s.str());
try
{
name = get_attr(lay, "name", string("Unnamed"));
name = get_attr(lay, "name", std::string("Unnamed"));
// XXX if no projection is given inherit from map? [DS]
std::string srs = get_attr(lay, "srs", map.srs());
@ -549,13 +549,13 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
lyr.setActive( * status );
}
optional<std::string> title = get_opt_attr<string>(lay, "title");
optional<std::string> title = get_opt_attr<std::string>(lay, "title");
if (title)
{
lyr.set_title( * title );
}
optional<std::string> abstract = get_opt_attr<string>(lay, "abstract");
optional<std::string> abstract = get_opt_attr<std::string>(lay, "abstract");
if (abstract)
{
lyr.set_abstract( * abstract );
@ -640,8 +640,8 @@ void map_parser::parse_layer( Map & map, ptree const & lay )
if (paramIter->first == "Parameter")
{
ensure_attrs(param, "Parameter", "name");
std::string name = get_attr<string>(param, "name");
std::string value = get_value<string>( param,
std::string name = get_attr<std::string>(param, "name");
std::string value = get_value<std::string>( param,
"datasource parameter");
params[name] = value;
}
@ -718,13 +718,13 @@ void map_parser::parse_rule( feature_type_style & style, ptree const & r )
std::string name;
try
{
name = get_attr( r, "name", string());
std::string title = get_attr( r, "title", string());
name = get_attr( r, "name", std::string());
std::string title = get_attr( r, "title", std::string());
rule rule(name,title);
optional<std::string> filter_expr =
get_opt_child<string>( r, "Filter");
get_opt_child<std::string>( r, "Filter");
if (filter_expr)
{
// TODO - can we use encoding defined for XML document for filter expressions?
@ -732,7 +732,7 @@ void map_parser::parse_rule( feature_type_style & style, ptree const & r )
}
optional<std::string> else_filter =
get_opt_child<string>(r, "ElseFilter");
get_opt_child<std::string>(r, "ElseFilter");
if (else_filter)
{
rule.set_else(true);
@ -823,7 +823,7 @@ void map_parser::parse_rule( feature_type_style & style, ptree const & r )
{
if ( ! name.empty() )
{
ex.append_context(string("in rule '") + name + "' in map '" + filename_ + "')");
ex.append_context(std::string("in rule '") + name + "' in map '" + filename_ + "')");
}
throw;
}
@ -831,9 +831,9 @@ void map_parser::parse_rule( feature_type_style & style, ptree const & r )
void map_parser::parse_metawriter_in_symbolizer(symbolizer_base &sym, ptree const &pt)
{
optional<std::string> writer = get_opt_attr<string>(pt, "meta-writer");
optional<std::string> writer = get_opt_attr<std::string>(pt, "meta-writer");
if (!writer) return;
optional<std::string> output = get_opt_attr<string>(pt, "meta-output");
optional<std::string> output = get_opt_attr<std::string>(pt, "meta-output");
sym.add_metawriter(*writer, output);
}
@ -844,8 +844,8 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym )
std::stringstream s;
s << "file,base,allow-overlap,ignore-placement,opacity,placement,transform,meta-writer,meta-output";
optional<std::string> file = get_opt_attr<string>(sym, "file");
optional<std::string> base = get_opt_attr<string>(sym, "base");
optional<std::string> file = get_opt_attr<std::string>(sym, "file");
optional<std::string> base = get_opt_attr<std::string>(sym, "base");
optional<boolean> allow_overlap =
get_opt_attr<boolean>(sym, "allow-overlap");
optional<boolean> ignore_placement =
@ -853,7 +853,7 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym )
optional<float> opacity =
get_opt_attr<float>(sym, "opacity");
optional<std::string> transform_wkt = get_opt_attr<string>(sym, "transform");
optional<std::string> transform_wkt = get_opt_attr<std::string>(sym, "transform");
if (file)
{
@ -900,7 +900,7 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym )
if (strict_)
throw config_error(ss.str()); // value_error here?
else
clog << "### WARNING: " << ss << endl;
std::clog << "### WARNING: " << ss << endl;
}
boost::array<double,6> matrix;
tr.store_to(&matrix[0]);
@ -912,7 +912,7 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym )
}
catch (image_reader_exception const & ex )
{
string msg("Failed to load image file '" + * file +
std::string msg("Failed to load image file '" + * file +
"': " + ex.what());
if (strict_)
{
@ -920,7 +920,7 @@ void map_parser::parse_point_symbolizer( rule & rule, ptree const & sym )
}
else
{
clog << "### WARNING: " << msg << endl;
std::clog << "### WARNING: " << msg << endl;
}
}
@ -963,9 +963,9 @@ void map_parser::parse_markers_symbolizer( rule & rule, ptree const & sym )
try
{
std::string filename("");
optional<std::string> file = get_opt_attr<string>(sym, "file");
optional<std::string> base = get_opt_attr<string>(sym, "base");
optional<std::string> transform_wkt = get_opt_attr<string>(sym, "transform");
optional<std::string> file = get_opt_attr<std::string>(sym, "file");
optional<std::string> base = get_opt_attr<std::string>(sym, "base");
optional<std::string> transform_wkt = get_opt_attr<std::string>(sym, "transform");
std::stringstream s;
//s << "file,opacity,spacing,max-error,allow-overlap,placement,";
@ -997,14 +997,14 @@ void map_parser::parse_markers_symbolizer( rule & rule, ptree const & sym )
}
catch (...)
{
string msg("Failed to load marker file '" + *file + "'!");
std::string msg("Failed to load marker file '" + *file + "'!");
if (strict_)
{
throw config_error(msg);
}
else
{
clog << "### WARNING: " << msg << endl;
std::clog << "### WARNING: " << msg << endl;
}
}
}
@ -1029,7 +1029,7 @@ void map_parser::parse_markers_symbolizer( rule & rule, ptree const & sym )
if (strict_)
throw config_error(ss.str()); // value_error here?
else
clog << "### WARNING: " << ss << endl;
std::clog << "### WARNING: " << ss << endl;
}
boost::array<double,6> matrix;
tr.store_to(&matrix[0]);
@ -1094,8 +1094,8 @@ void map_parser::parse_line_pattern_symbolizer( rule & rule, ptree const & sym )
ensure_attrs(sym, "LinePatternSymbolizer", "file,base,meta-writer,meta-output");
try
{
std::string file = get_attr<string>(sym, "file");
optional<std::string> base = get_opt_attr<string>(sym, "base");
std::string file = get_attr<std::string>(sym, "file");
optional<std::string> base = get_opt_attr<std::string>(sym, "base");
try
{
@ -1117,7 +1117,7 @@ void map_parser::parse_line_pattern_symbolizer( rule & rule, ptree const & sym )
}
catch (image_reader_exception const & ex )
{
string msg("Failed to load image file '" + file +
std::string msg("Failed to load image file '" + file +
"': " + ex.what());
if (strict_)
{
@ -1125,7 +1125,7 @@ void map_parser::parse_line_pattern_symbolizer( rule & rule, ptree const & sym )
}
else
{
clog << "### WARNING: " << msg << endl;
std::clog << "### WARNING: " << msg << endl;
}
}
}
@ -1142,8 +1142,8 @@ void map_parser::parse_polygon_pattern_symbolizer( rule & rule,
ensure_attrs(sym, "PolygonPatternSymbolizer", "file,base,alignment,meta-writer,meta-output");
try
{
std::string file = get_attr<string>(sym, "file");
optional<std::string> base = get_opt_attr<string>(sym, "base");
std::string file = get_attr<std::string>(sym, "file");
optional<std::string> base = get_opt_attr<std::string>(sym, "base");
try
{
@ -1169,7 +1169,7 @@ void map_parser::parse_polygon_pattern_symbolizer( rule & rule,
}
catch (image_reader_exception const & ex )
{
string msg("Failed to load image file '" + file +
std::string msg("Failed to load image file '" + file +
"': " + ex.what());
if (strict_)
{
@ -1177,7 +1177,7 @@ void map_parser::parse_polygon_pattern_symbolizer( rule & rule,
}
else
{
clog << "### WARNING: " << msg << endl;
std::clog << "### WARNING: " << msg << endl;
}
}
}
@ -1220,7 +1220,7 @@ void map_parser::parse_text_symbolizer( rule & rule, ptree const & sym )
placement_finder = text_placements_ptr(new text_placements_dummy());
}
std::string name = get_attr<string>(sym, "name");
std::string name = get_attr<std::string>(sym, "name");
optional<std::string> face_name =
get_opt_attr<std::string>(sym, "face-name");
@ -1445,7 +1445,7 @@ void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
ensure_attrs(sym, "ShieldSymbolizer", s.str());
try
{
std::string name = get_attr<string>(sym, "name");
std::string name = get_attr<std::string>(sym, "name");
optional<std::string> face_name =
get_opt_attr<std::string>(sym, "face-name");
@ -1456,10 +1456,10 @@ void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
unsigned size = get_attr(sym, "size", 10U);
color fill = get_attr(sym, "fill", color(0,0,0));
std::string image_file = get_attr<string>(sym, "file");
optional<std::string> base = get_opt_attr<string>(sym, "base");
std::string image_file = get_attr<std::string>(sym, "file");
optional<std::string> base = get_opt_attr<std::string>(sym, "base");
optional<std::string> transform_wkt = get_opt_attr<string>(sym, "transform");
optional<std::string> transform_wkt = get_opt_attr<std::string>(sym, "transform");
try
{
if( base )
@ -1645,7 +1645,7 @@ void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
if (strict_)
throw config_error(ss.str()); // value_error here?
else
clog << "### WARNING: " << ss << endl;
std::clog << "### WARNING: " << ss << endl;
}
boost::array<double,6> matrix;
tr.store_to(&matrix[0]);
@ -1673,7 +1673,7 @@ void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
}
catch (image_reader_exception const & ex )
{
string msg("Failed to load image file '" + image_file +
std::string msg("Failed to load image file '" + image_file +
"': " + ex.what());
if (strict_)
{
@ -1681,7 +1681,7 @@ void map_parser::parse_shield_symbolizer( rule & rule, ptree const & sym )
}
else
{
clog << "### WARNING: " << msg << endl;
std::clog << "### WARNING: " << msg << endl;
}
}
@ -1724,7 +1724,7 @@ void map_parser::parse_stroke(stroke & strk, ptree const & sym)
if (dash_offset) strk.set_dash_offset(*dash_offset);
// stroke-dasharray
optional<string> str = get_opt_attr<string>(sym,"stroke-dasharray");
optional<std::string> str = get_opt_attr<std::string>(sym,"stroke-dasharray");
if (str)
{
tokenizer<> tok (*str);