+ specialise svg parsers to expect const char* input
This commit is contained in:
parent
d0b1e62c2d
commit
6030efab50
5 changed files with 49 additions and 35 deletions
|
@ -27,16 +27,19 @@
|
|||
|
||||
namespace mapnik { namespace svg {
|
||||
|
||||
template <typename PathType>
|
||||
bool parse_path(std::string const& wkt, PathType & p);
|
||||
template <typename PathType>
|
||||
bool parse_path(const char * wkt, PathType & p);
|
||||
|
||||
template <typename PathType>
|
||||
bool parse_points(std::string const& wkt, PathType & p);
|
||||
template <typename PathType>
|
||||
bool parse_points(const char * wkt, PathType & p);
|
||||
|
||||
template <typename TransformType>
|
||||
bool parse_transform(std::string const& wkt, TransformType & tr);
|
||||
template <typename TransformType>
|
||||
bool parse_transform(const char * wkt, TransformType & tr);
|
||||
|
||||
}}
|
||||
template <typename TransformType>
|
||||
bool parse_transform(std::string const& wkt, TransformType & tr);
|
||||
|
||||
}}
|
||||
|
||||
|
||||
#endif // SVG_PATH_PARSER_HPP
|
||||
|
|
|
@ -199,8 +199,7 @@ void svg_parser::parse_attr(const xmlChar * name, const xmlChar * value )
|
|||
if (xmlStrEqual(name, BAD_CAST "transform"))
|
||||
{
|
||||
agg::trans_affine tr;
|
||||
std::string wkt((const char*) value);
|
||||
mapnik::svg::parse_transform(wkt,tr);
|
||||
mapnik::svg::parse_transform((const char*) value,tr);
|
||||
path_.transform().premultiply(tr);
|
||||
}
|
||||
else if (xmlStrEqual(name, BAD_CAST "fill"))
|
||||
|
@ -312,9 +311,8 @@ void svg_parser::parse_path(xmlTextReaderPtr reader)
|
|||
{
|
||||
path_.begin_path();
|
||||
parse_attr(reader);
|
||||
|
||||
std::string wkt((const char*) value);
|
||||
if (!mapnik::svg::parse_path(wkt, path_))
|
||||
|
||||
if (!mapnik::svg::parse_path((const char*) value, path_))
|
||||
{
|
||||
std::runtime_error("can't parse PATH\n");
|
||||
}
|
||||
|
|
|
@ -35,17 +35,17 @@
|
|||
namespace mapnik { namespace svg {
|
||||
|
||||
template <typename PathType>
|
||||
bool parse_path(std::string const& wkt, PathType & p)
|
||||
bool parse_path(const char* wkt, PathType & p)
|
||||
{
|
||||
using namespace boost::spirit;
|
||||
typedef std::string::const_iterator iterator_type;
|
||||
typedef const char* iterator_type;
|
||||
typedef ascii::space_type skip_type;
|
||||
svg_path_grammar<iterator_type,skip_type,PathType> g(p);
|
||||
iterator_type first = wkt.begin();
|
||||
iterator_type last = wkt.end();
|
||||
iterator_type first = wkt;
|
||||
iterator_type last = wkt + std::strlen(wkt);
|
||||
return qi::phrase_parse(first, last, g, skip_type());
|
||||
}
|
||||
|
||||
template bool parse_path<svg_converter_type>(std::string const&, svg_converter_type&);
|
||||
template bool parse_path<svg_converter_type>(const char*, svg_converter_type&);
|
||||
|
||||
}}
|
||||
|
|
|
@ -30,17 +30,17 @@
|
|||
namespace mapnik { namespace svg {
|
||||
|
||||
template <typename PathType>
|
||||
bool parse_points(std::string const& wkt, PathType & p)
|
||||
bool parse_points(const char* wkt, PathType & p)
|
||||
{
|
||||
using namespace boost::spirit;
|
||||
typedef std::string::const_iterator iterator_type;
|
||||
typedef const char* iterator_type;
|
||||
typedef ascii::space_type skip_type;
|
||||
svg_points_grammar<iterator_type,skip_type,PathType> g(p);
|
||||
iterator_type first = wkt.begin();
|
||||
iterator_type last = wkt.end();
|
||||
iterator_type first = wkt;
|
||||
iterator_type last = wkt + std::strlen(wkt);
|
||||
return qi::phrase_parse(first, last, g, skip_type());
|
||||
}
|
||||
|
||||
template bool parse_points<svg_converter_type>(std::string const&, svg_converter_type&);
|
||||
template bool parse_points<svg_converter_type>(const char*, svg_converter_type&);
|
||||
|
||||
}}
|
||||
|
|
|
@ -30,18 +30,31 @@
|
|||
|
||||
namespace mapnik { namespace svg {
|
||||
|
||||
template <typename TransformType>
|
||||
bool parse_transform(std::string const& wkt, TransformType & p)
|
||||
{
|
||||
using namespace boost::spirit;
|
||||
typedef std::string::const_iterator iterator_type;
|
||||
typedef ascii::space_type skip_type;
|
||||
svg_transform_grammar<iterator_type,skip_type,TransformType> g(p);
|
||||
iterator_type first = wkt.begin();
|
||||
iterator_type last = wkt.end();
|
||||
return qi::phrase_parse(first, last, g, skip_type());
|
||||
}
|
||||
template <typename TransformType>
|
||||
bool parse_transform(const char * wkt, TransformType & p)
|
||||
{
|
||||
using namespace boost::spirit;
|
||||
typedef const char * iterator_type;
|
||||
typedef ascii::space_type skip_type;
|
||||
svg_transform_grammar<iterator_type,skip_type,TransformType> g(p);
|
||||
iterator_type first = wkt;
|
||||
iterator_type last = wkt + std::strlen(wkt);
|
||||
return qi::phrase_parse(first, last, g, skip_type());
|
||||
}
|
||||
|
||||
template bool parse_transform<agg::trans_affine>(std::string const&, agg::trans_affine&);
|
||||
template <typename TransformType>
|
||||
bool parse_transform(std::string const& wkt, TransformType & p)
|
||||
{
|
||||
using namespace boost::spirit;
|
||||
typedef std::string::const_iterator iterator_type;
|
||||
typedef ascii::space_type skip_type;
|
||||
svg_transform_grammar<iterator_type,skip_type,TransformType> g(p);
|
||||
iterator_type first = wkt.begin();
|
||||
iterator_type last = wkt.end();
|
||||
return qi::phrase_parse(first, last, g, skip_type());
|
||||
}
|
||||
|
||||
}}
|
||||
template bool parse_transform<agg::trans_affine>(const char*, agg::trans_affine&);
|
||||
template bool parse_transform<agg::trans_affine>(std::string const& , agg::trans_affine&);
|
||||
|
||||
}}
|
||||
|
|
Loading…
Add table
Reference in a new issue