Fix handling of empty XML nodes.

Closes #1106.
This commit is contained in:
Hermann Kraus 2012-03-03 01:12:23 +01:00
parent cc547385e6
commit 2bf9d9dbdf
2 changed files with 8 additions and 6 deletions

View file

@ -437,6 +437,12 @@ inline boost::optional<color> get_optional(boost::property_tree::ptree const& no
return result;
}
static inline bool has_child(boost::property_tree::ptree const& node, std::string const& name)
{
boost::optional<std::string> str = node.get_optional<std::string>(name);
return str;
}
} // end of namespace mapnik
#endif // MAPNIK_PTREE_HELPERS_HPP

View file

@ -841,16 +841,12 @@ void map_parser::parse_rule( feature_type_style & style, ptree const & r )
rule.set_filter(parse_expr(*filter_expr));
}
optional<std::string> else_filter =
get_opt_child<std::string>(r, "ElseFilter");
if (else_filter)
if (has_child(r, "ElseFilter"))
{
rule.set_else(true);
}
optional<std::string> also_filter =
get_opt_child<std::string>(r, "AlsoFilter");
if (also_filter)
if (has_child(r, "AlsoFilter"))
{
rule.set_also(true);
}