clean up impl of attr checking for warnings - no functional change just simplified

This commit is contained in:
Dane Springmeyer 2011-11-30 16:48:01 -08:00
parent 2037cb0d46
commit c731797c53

View file

@ -255,10 +255,10 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base
} }
else else
{ {
std::ostringstream s; std::ostringstream s_err;
s << "failed to parse 'maximum-extent'"; s << "failed to parse 'maximum-extent'";
if ( strict_ ) if ( strict_ )
throw config_error(s.str()); throw config_error(s_err.str());
else else
std::clog << "### WARNING: " << s.str() << std::endl; std::clog << "### WARNING: " << s.str() << std::endl;
} }
@ -311,6 +311,7 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base
} }
} }
map.set_extra_attributes(extra_attr); map.set_extra_attributes(extra_attr);
} }
catch (const config_error & ex) catch (const config_error & ex)
@ -2185,20 +2186,12 @@ std::string map_parser::ensure_relative_to_xml( boost::optional<std::string> opt
void map_parser::ensure_attrs(ptree const& sym, std::string name, std::string attrs) void map_parser::ensure_attrs(ptree const& sym, std::string name, std::string attrs)
{ {
typedef ptree::key_type::value_type Ch; typedef ptree::key_type::value_type Ch;
//typedef boost::property_tree::xml_parser::xmlattr<Ch> x_att;
std::set<std::string> attr_set;
boost::split(attr_set, attrs, boost::is_any_of(","));
for (ptree::const_iterator itr = sym.begin(); itr != sym.end(); ++itr)
{
//ptree::value_type const& v = *itr;
if (itr->first == boost::property_tree::xml_parser::xmlattr<Ch>())
{
optional<const ptree &> attribs = sym.get_child_optional( boost::property_tree::xml_parser::xmlattr<Ch>() ); optional<const ptree &> attribs = sym.get_child_optional( boost::property_tree::xml_parser::xmlattr<Ch>() );
if (attribs) if (attribs)
{ {
std::set<std::string> attr_set;
boost::split(attr_set, attrs, boost::is_any_of(","));
std::ostringstream s(""); std::ostringstream s("");
s << "### " << name << " properties warning: "; s << "### " << name << " properties warning: ";
int missing = 0; int missing = 0;
@ -2208,20 +2201,27 @@ void map_parser::ensure_attrs(ptree const& sym, std::string name, std::string at
bool found = (attr_set.find(name) != attr_set.end()); bool found = (attr_set.find(name) != attr_set.end());
if (!found) if (!found)
{ {
if (missing) s << ","; if (missing)
{
s << ",";
}
s << "'" << name << "'"; s << "'" << name << "'";
++missing; ++missing;
} }
} }
if (missing) { if (missing) {
if (missing > 1) s << " are"; if (missing > 1)
else s << " is"; {
s << " are";
}
else
{
s << " is";
}
s << " invalid, acceptable values are:\n'" << attrs << "'\n"; s << " invalid, acceptable values are:\n'" << attrs << "'\n";
std::clog << s.str(); std::clog << s.str();
} }
} }
} }
}
}
} // end of namespace mapnik } // end of namespace mapnik