move dasharray parser to cpp file - refs #2439

This commit is contained in:
Dane Springmeyer 2014-09-29 12:07:15 -07:00
parent 953f4b700c
commit 688e97e148
5 changed files with 5 additions and 37 deletions

View file

@ -410,7 +410,7 @@ struct evaluate_expression_wrapper<mapnik::dash_array>
dash_array dash;
std::vector<double> buf;
std::string str = val.to_string();
if (util::parse_dasharray(str.begin(),str.end(),buf))
if (util::parse_dasharray(str,buf))
{
util::add_dashes(buf,dash);
}

View file

@ -37,6 +37,7 @@
#include <mapnik/config_error.hpp>
#include <mapnik/evaluate_global_attributes.hpp>
#include <mapnik/parse_transform.hpp>
#include <mapnik/util/dasharray_parser.hpp>
#include <mapnik/util/variant.hpp>
namespace mapnik {
@ -395,7 +396,7 @@ struct set_symbolizer_property_impl<Symbolizer,dash_array,false>
{
std::vector<double> buf;
dash_array dash;
if (util::parse_dasharray((*str).begin(),(*str).end(),buf) && util::add_dashes(buf,dash))
if (util::parse_dasharray(*str,buf) && util::add_dashes(buf,dash))
{
put(sym,key,dash);
}

View file

@ -23,42 +23,12 @@
#ifndef MAPNIK_UTIL_DASHARRAY_PARSER_HPP
#define MAPNIK_UTIL_DASHARRAY_PARSER_HPP
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <vector>
#include <string>
namespace mapnik { namespace util {
template <typename Iterator>
bool parse_dasharray(Iterator first, Iterator last, std::vector<double>& dasharray)
{
using namespace boost::spirit;
qi::double_type double_;
qi::_1_type _1;
qi::lit_type lit;
qi::char_type char_;
qi::ascii::space_type space;
qi::no_skip_type no_skip;
// SVG
// dasharray ::= (length | percentage) (comma-wsp dasharray)?
// no support for 'percentage' as viewport is unknown at load_map
//
bool r = qi::phrase_parse(first, last,
(double_[boost::phoenix::push_back(boost::phoenix::ref(dasharray), _1)] %
no_skip[char_(", ")]
| lit("none")),
space);
if (first != last)
{
return false;
}
return r;
}
bool parse_dasharray(std::string const& value, std::vector<double>& dasharray);
inline bool add_dashes(std::vector<double> & buf, std::vector<std::pair<double,double> > & dash)
{

View file

@ -38,10 +38,6 @@
#include <mapnik/symbolizer_keys.hpp>
#include <mapnik/symbolizer.hpp>
// fusion
//#include <boost/fusion/include/at_c.hpp>
//#include <boost/fusion/container/vector.hpp>
// agg
#include "agg_math_stroke.h"
#include "agg_trans_affine.h"

View file

@ -142,6 +142,7 @@ else: # unix, non-macos
source = Split(
"""
dasharray_parser.cpp
expression_grammar.cpp
fs.cpp
request.cpp