From 6f3860d658bfe6d879f288fda0edc2ed00d751b0 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 30 Nov 2011 16:48:01 -0800 Subject: [PATCH] clean up impl of attr checking for warnings - no functional change just simplified --- src/load_map.cpp | 74 ++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/load_map.cpp b/src/load_map.cpp index 9b25dec5f..623c9948d 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -255,10 +255,10 @@ void map_parser::parse_map( Map & map, ptree const & pt, std::string const& base } else { - std::ostringstream s; + std::ostringstream s_err; s << "failed to parse 'maximum-extent'"; if ( strict_ ) - throw config_error(s.str()); + throw config_error(s_err.str()); else 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); } catch (const config_error & ex) @@ -2185,43 +2186,42 @@ std::string map_parser::ensure_relative_to_xml( boost::optional opt void map_parser::ensure_attrs(ptree const& sym, std::string name, std::string attrs) { - typedef ptree::key_type::value_type Ch; - //typedef boost::property_tree::xml_parser::xmlattr x_att; - - std::set attr_set; - boost::split(attr_set, attrs, boost::is_any_of(",")); - for (ptree::const_iterator itr = sym.begin(); itr != sym.end(); ++itr) + optional attribs = sym.get_child_optional( boost::property_tree::xml_parser::xmlattr() ); + if (attribs) { - //ptree::value_type const& v = *itr; - if (itr->first == boost::property_tree::xml_parser::xmlattr()) - { - optional attribs = sym.get_child_optional( boost::property_tree::xml_parser::xmlattr() ); - if (attribs) - { - std::ostringstream s(""); - s << "### " << name << " properties warning: "; - int missing = 0; - for (ptree::const_iterator it = attribs.get().begin(); it != attribs.get().end(); ++it) - { - std::string name = it->first; - bool found = (attr_set.find(name) != attr_set.end()); - if (!found) - { - if (missing) s << ","; - s << "'" << name << "'"; - ++missing; - } - } - if (missing) { - if (missing > 1) s << " are"; - else s << " is"; - s << " invalid, acceptable values are:\n'" << attrs << "'\n"; - std::clog << s.str(); - } - } - } - } + std::set attr_set; + boost::split(attr_set, attrs, boost::is_any_of(",")); + std::ostringstream s(""); + s << "### " << name << " properties warning: "; + int missing = 0; + for (ptree::const_iterator it = attribs.get().begin(); it != attribs.get().end(); ++it) + { + std::string name = it->first; + bool found = (attr_set.find(name) != attr_set.end()); + if (!found) + { + if (missing) + { + s << ","; + } + s << "'" << name << "'"; + ++missing; + } + } + if (missing) { + if (missing > 1) + { + s << " are"; + } + else + { + s << " is"; + } + s << " invalid, acceptable values are:\n'" << attrs << "'\n"; + std::clog << s.str(); + } + } } } // end of namespace mapnik