+ change ingterface to work with std::string

This commit is contained in:
Artem Pavlenko 2011-06-07 16:13:54 +00:00
parent 3d81a07f06
commit bc3d784b85

View file

@ -44,14 +44,14 @@ class MAPNIK_DECL color_factory : boost::noncopyable
{ {
public: public:
static void init_from_string(color & c, char const* css_color) static void init_from_string(color & c, std::string const& css_color)
{ {
typedef char const* iterator_type; typedef std::string::const_iterator iterator_type;
typedef mapnik::css_color_grammar<iterator_type> css_color_grammar; typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
css_color_grammar g; css_color_grammar g;
iterator_type first = css_color; iterator_type first = css_color.begin();
iterator_type last = css_color + std::strlen(css_color); iterator_type last = css_color.end();
bool result = bool result =
boost::spirit::qi::phrase_parse(first, boost::spirit::qi::phrase_parse(first,
last, last,
@ -65,7 +65,7 @@ public:
} }
} }
static color from_string(char const* css_color) static color from_string(std::string const& css_color)
{ {
color c; color c;
init_from_string(c,css_color); init_from_string(c,css_color);
@ -83,14 +83,14 @@ class MAPNIK_DECL color_factory : boost::noncopyable
{ {
public: public:
static void init_from_string(color & c, char const* css_color) static void init_from_string(color & c, std::string const& css_color)
{ {
typedef char const* iterator_type; typedef std::string::const_iterator iterator_type;
typedef mapnik::css_color_grammar<iterator_type> css_color_grammar; typedef mapnik::css_color_grammar<iterator_type> css_color_grammar;
css_color_grammar g; css_color_grammar g;
iterator_type first = css_color; iterator_type first = css_color.begin();
iterator_type last = css_color + std::strlen(css_color); iterator_type last = css_color.end();
mapnik::css css_; mapnik::css css_;
bool result = bool result =
boost::spirit::qi::phrase_parse(first, boost::spirit::qi::phrase_parse(first,
@ -109,7 +109,7 @@ public:
c.set_alpha(css_.a); c.set_alpha(css_.a);
} }
static color from_string(char const* css_color) static color from_string(std::string const& css_color)
{ {
color c; color c;
init_from_string(c,css_color); init_from_string(c,css_color);