replace boost::spirit::karma alternate operator (uses boost::variant) with direct util::variant to string conversion

This commit is contained in:
artemp 2014-08-08 15:53:28 +01:00
parent 6095df6702
commit 784d24828f
2 changed files with 7 additions and 9 deletions

View file

@ -126,14 +126,13 @@ struct utf8
} }
}; };
struct value_base struct extract_string
{ {
template <typename T> template <typename T>
struct result { using type = mapnik::value_base const&; }; struct result { using type = std::string; };
std::string operator() (mapnik::value const& val) const
mapnik::value_base const& operator() (mapnik::value const& val) const
{ {
return val.base(); return val.to_expression_string();
} }
}; };
@ -159,12 +158,12 @@ struct feature_generator_grammar:
escaped_string<OutputIterator> escaped_string_; escaped_string<OutputIterator> escaped_string_;
karma::rule<OutputIterator, mapnik::feature_impl const&()> properties; karma::rule<OutputIterator, mapnik::feature_impl const&()> properties;
karma::rule<OutputIterator, pair_type()> pair; karma::rule<OutputIterator, pair_type()> pair;
karma::rule<OutputIterator, void(mapnik::value const&)> value; karma::rule<OutputIterator, mapnik::value_base const&(mapnik::value const&)> value;
karma::rule<OutputIterator, mapnik::value_null()> value_null_; karma::rule<OutputIterator, mapnik::value_null()> value_null_;
karma::rule<OutputIterator, mapnik::value_unicode_string()> ustring; karma::rule<OutputIterator, mapnik::value_unicode_string()> ustring;
typename karma::int_generator<mapnik::value_integer,10, false> int__; typename karma::int_generator<mapnik::value_integer,10, false> int__;
boost::phoenix::function<get_id> id_; boost::phoenix::function<get_id> id_;
boost::phoenix::function<value_base> value_base_; boost::phoenix::function<extract_string> extract_string_;
boost::phoenix::function<utf8> utf8_; boost::phoenix::function<utf8> utf8_;
std::string quote_; std::string quote_;
}; };

View file

@ -92,9 +92,8 @@ feature_generator_grammar<OutputIterator>::feature_generator_grammar()
<< value(boost::phoenix::at_c<1>(_val)) << value(boost::phoenix::at_c<1>(_val))
; ;
value = kstring[_1 = "\"FIXME\""] // FIXME (value_null_| bool_ | int__ | double_ | ustring)[_1 = value_base_(_r1)] value = kstring[_1 = extract_string_(_r1)]
; ;
value_null_ = kstring[_1 = "null"] value_null_ = kstring[_1 = "null"]
; ;